Conventionally name resolution, that is the mapping of IP addresses to host names and vice versa, is done by a DNS (Domain Name System) server.
You probably have an internet router that provides DNS for your local network. There is an offside chance, that your router allows you to add entries to its DNS, but usually customer grade hardware does not offer this. Won't hurt to check, since this would be the easiest way.
As this will probably not be possible, there are multiple ways to go
Note: the domain
.local refers to a system known as m(ulticast)DNS, aka zeroconf/bonjour/avahi - for technical details see the RFC. It provides name resolution and service announcement if there is no dedicated DNS server available, although on OS X(bonjour) and Ubuntu (avahi) it is enabled by default.
Update: I found the avahi method not immediately viable and setting up a local DNS only makes sense if it can run as the primary DNS for the network.
/etc/hosts on each client on the LAN. This method is straightforward, but a little impractical, if IPs or hostnames change frequently.
As noted above, the
avahi-daemon is running by default on Ubuntu. You can configure the machine to announce itself under multiple names, but there needs to be a mDNS client running on each machine in the LAN, that should resolve the new hostname (on Windows machines, Apples bonjour service is installed with iTunes).
Give it a try by adding
/etc/avahi/hosts and restart the service with
sudo service avahi-daemon restart. Now try if the new hostname is resolved e.g. by pinging it from another machine.
Update: The described method to use avahi to setup an alias does not work! Avahi will not allow to bind multiple hostnames to the same IP, as it will always try to register a corresponding PTR, which leads to a collision. This is expected and good behavior.
However, there exists an extension avahi-alias which allows to register aliases (CNAME). Unfortunately, those aliases will not be recognized by (at least) Windows clients, but as long as you're only running clients with avahi, this provides a real option.
To install avahi on a Ubuntu system, do
sudo apt-get install avahi-daemon libnss-mdns
eth0 is the interface connecting to the LAN.
dnsmasq automatically reads
/etc/hosts, so add your hostname to
hosts like stated above.
Finally add the machine running dnsmasq to the list of DNS servers on each client.
Update: You probably have a DNS server running already, e.g on your internet router. The clients will send DNS queries to that server. You cannot simply add a secondary DNS to your clients config, as it will only ever be queried if the primary DNS is unreachable. Unless you're running an always-on machine that can become the primary DNS for the network, there is no way to make this work.
In Summary: In a Linux-only environment, where you can run the avahi-daemon on each client, the avahi method actually provides a solution. I tried this myself.
Since you probably cannot turn a machine into an always-on DNS server, installing and configuring
dnsmasq is not advised.
Still, the most straightforward if a little cumbersome method, is to add an entry to the hosts file on each client!
Your recent problem with DNS resolution probably comes from running dnsmasq. I now actually discourage using dnsmasq, since it will not solve your problem. Stop the service
sudo service dnsmasq stop. Then try
host -v ro.archive.ubuntu.com. It should resolve using Google's DNS 18.104.22.168 as configured in
Furthermore, if you go with the
hosts method, do not append the domain
.local, as it is reserved for mDNS. Instead, just put