Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 1.2.3.4:
   mail.example.com
   www.example.com
eth0:1, bound to WAN interface 1.2.3.5:
   www.other-domain.com
eth1, bound to LAN 192.168.1.123:
   some-clever-hostname

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

Thanks!

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
add comment

1 Answer

up vote 1 down vote accepted

Putting localhost in /etc/hostname and

127.0.0.1 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
add comment

Your Answer

 
discard

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.