/etc/hosts file for a multi-homed, multi-domain machine?
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?
Solution 1:
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).