1

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.

vfclists
  • 7,531
  • 14
  • 53
  • 79
  • 1
    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 00:47

2 Answers2

1

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.

aecolley
  • 2,177
  • 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
1

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.