Server Fault is a question and answer site for system and network administrators. 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 server (debian) with two network interfaces that I would like to host multiple services and domains on; it is not entirely clear to me how the hosts file should be set up. Example:

eth0, bound to WAN interface
eth0:1, bound to WAN interface
eth1, bound to LAN

What should my hosts file look like? (including localhost,localhost.localdomain, etc.) Should I use DNS for some of these entries? Which ones?


EDIT: What if I was unable to utilize a DNS server, for instance in a testing environment?

share|improve this question
Usually you don't put anything in the hosts file; it usually all goes in DNS. What exactly are you trying to accomplish? You stated you are hosting services for two domains, but you didn't state why this is important. – Chris S Jun 16 '10 at 16:58
This test is currently in a local-DNS-free environment (i.e. 3rd-party DNS is used to point The World to the two public interfaces, however, there is no local DNS server; I use a hosts file in a private git repo). – mikewaters Jun 16 '10 at 18:02
You don't have DNS on the lan, but do you have a dhcp server? If you haven't yet, dnsmasq is a good fit. Otherwise, avahi-autoipd, or host files. – Tobu Jun 16 '10 at 21:01
up vote 1 down vote accepted

Putting localhost in /etc/hostname and localhost.localdomain localhost

in /etc/hosts is fine. The mappings can be set in DNS, and you can set the rest explicitly (apache will have ServerName configured inside virtual hosts, etc).

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.