1

I have a cloud server running Debian 7. My domain (www.domain.com and domain.com) both have an A record pointing to the static IP address of my cloud server.

On the cloud server itself, what should my /etc/hosts and /etc/hostname be set as?

I plan to have multiple servers, so I started labeling the servers as:

web01-east 
web01-west 
sql01-east 
sql01-west 

so that I know the location of each server.

Should the /etc/hosts look like:

web01-east 

or

web01-east.domain.com

And should the /etc/hostnames look like:

1.1.1.1 web01-east

or

1.1.1.1 web01-east.domain.com
1

I have a clustered setup where I named my hosts in /etc/host as:

192.168.0.5    master.local
XX.XX.XX.XX    www.master.com

192.168.0.6    node01.master.local
YY.YY.YY.YY    node01.master.com

192.168.0.7    node02.master.local
ZZ.ZZ.ZZ.ZZ    node02.master.com

With this I have a mapping of their private IPs, using .local and their public facing IPs without it. The www.master.com is in DNS. The other public IPs are not in DNS. I use this setup on AWS EC2 instances today for my Nginx clusters and it works well. Adding a new node is then a mindless operation and a simple cluster configuration.

I use the public name (without local) as each server's hostname.

You can put pretty much anything you want in the hosts file. The names are local to that machine anyway. It's really how you want to manage it.

0

The /etc/hosts file has the entry of the server's hostname. If you wish to point a domain locally on that server you can add the entry of that domain as well.

Ideally it is a below/

127.0.0.1 localhost.localdomain localhost xx.xx.xx.xx server.yourdomain.com server

Replace xx.xx.xx.xx with your actual server IP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.