Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

If you have a list of servers all linking to each other by static addresses, is there some kind of hosts.additional you can use as some kind of file based DNS?

ie The hosts file contains static information and the hosts.additional contains the address which change regularly.

share|improve this question
Why are your servers' addresses "chang[ing] regularly"? – Ignacio Vazquez-Abrams Oct 19 '12 at 14:18
@IgnacioVazquez-Abrams I want to set up a poor mans DNS until I set up a DNS server later on. It is simple and I can quickly see where the servers are in /etc/hosts at any location – vfclists Oct 19 '12 at 17:15
@vfclists: the easiest way to do this is with avahi. Install it and enable at least one service on each host. Add .local to your DNS search path. Everything will be able to resolve everything else. – bahamat Oct 20 '12 at 0:47
up vote 1 down vote accepted

No, there's only one /etc/hosts. You could rebuild it with a cron entry every so often, perhaps by downloading it from a central server which you can update. rsync will do the work for you. Of course, this assumes you have a good reason to avoid setting up DNS.

share|improve this answer
I was hoping otherwise rather in vain – vfclists Oct 19 '12 at 14:15
Depending on exactly what you want to do, the environment variable HOSTALIASES might be useful to you. It names a file which maps single-word hostnames to other hostname. If all actual addresses are in the static /etc/hosts then you can put changeable aliases in $HOSTALIASES and it should work. See hostname(7). – aecolley Oct 19 '12 at 16:00

Under Linux, /etc/hosts is hard-coded in the libc source. You can't change the file name or have more than one.

My recommendation is to run a DNS server on your machine. It's very easy, it will improve performance because the DNS server also caches DNS requests, and you can centralize the information on a small network. Also, you get to feed data from more than one file. I wrote a dnsmasq setup guide in this answer. You'll want to use multiple addn-hosts directives.

share|improve this answer

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.