Thursday, August 28, 2014

networking - /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?



Answer



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).


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...