Mobile app version of vmapp.org
Login or Join
Gail5422790

: Editing hosts and hostname files for multiple servers 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

@Gail5422790

Posted in: #CloudHosting

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

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Gail5422790

2 Comments

Sorted by latest first Latest Oldest Best

 

@Murphy175

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

192.168.0.5 master.local
XX.XX.XX.XX 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 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.

10% popularity Vote Up Vote Down


 

@Sarah324

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme