Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a network which connects a couple of hosts. I would like to be able to reach other hosts from one of them using the hostname. I just discovered the ".local" domain, which is available through avahi and /etc/nsswitch.conf. But it's not set up this way on my servers. And I don't want to create an entry in my dns server. Is there an other way to do so ?

share|improve this question
Avahi mDNS is pretty good for you needs. See answer about /etc/nsswitch.conf for how to configure it. – ulidtko Jan 28 '11 at 22:23
up vote 8 down vote accepted

Your /etc/nsswitch.conf should already have this for mDNS (avahi):

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

Just install avahi-daemon on the machines you want talking to eachother, and you should be set to use HOSTNAME.local like this:

ssh yourmachine.local
share|improve this answer
This is the answer I wish I could upvote twice. – ulidtko Jan 28 '11 at 22:33

An alternative is to add an entry in your /etc/hosts file:

gksudo gedit /etc/hosts

An entry takes the form host.domain or just host.

If you do that, you can now for example ssh host and it will connect to

share|improve this answer
Sorry, i forget to mention that i doesn't want to do so for two reason. First for secuity reasons, these machines a server. And i think, it could be an issue. Secondly, i know that my hosts will changes there ip adresse soon. And i don't want to update this conf every time. edit: a third reason, i use dhcp, so the network manager will generate a new one frequently. But i know there is a trick to do let it do it. – benzen Jan 28 '11 at 17:36

I found another solution. Using the file, /etc/dhccp3/dhcient.conf There is a line starting like this, send host-name This could be modified to send host-name 'server1'

This solution look nice, but i don't know if the every machine which use the same dns will see my "server1" hostname.

Another bad side to this solution, i need to specify the hostname here and in the /etc/hosts

I just know that this file (/etc/dhcp3/dhclient.conf) is not a script, so i can't use a environnement variable to fill this line correctly.

share|improve this answer

You can let dynamic DHCP add the entry in DNS, instead of yourself.

share|improve this answer
But i don't want them to be expose to the whole internet.Just to find them in my localnetwork – benzen Jan 28 '11 at 18:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.