Web Hosting Talk







View Full Version : A question regarding etc/hosts


jellday
06-03-2011, 04:37 AM
It is said in Linode's doc that:
Update /etc/hosts
Next, edit your /etc/hosts file to resemble the following example, replacing "plato" with your chosen hostname, "example.com" with your system's domain name, and "12.34.56.78" with your system's IP address. As with the hostname, the domain name part of your FQDN does not necesarily need to have any relationship to websites or other services hosted on the server (although it may if you wish). As an example, you might host "www.something.com" on your server, but the system's FQDN might be "mars.somethingelse.com."
File:/etc/hosts

127.0.0.1 localhost.localdomain localhost
12.34.56.78 plato.example.com plato

Since it says "the domain name part of your FQDN does not necesarily need to have any relationship to websites or other services hosted on the server", does that mean I can use "plato.somenonexistdomain.com" on the second line?

Does that mean, only the first IP part and the last hostname part is need to be true?

vpswing
07-04-2011, 04:57 AM
My knowledge is a little rusty, but yes, you can put anything there in the /etc/hosts file.

Example:
--------

127.0.0.1 localhost.localdomain localhost
xx.xx.xx.xx server1.yourdomain.com server1
yy.yy.yy.yy server2.anotherdomain.com server2


xx.xx.xx.xx is the IP addr. of your VPS - and the FQDN (server1.yourdomain.com) should come first before 'server1'

Subsequent entries (e.g. another IP addr: yy.yy.yy.yy correspond with another domain - yy.yy.yy.yy can be another IP on the same VPS or another server on the internet).

Once you've edited the /etc/hosts, you may need to restart named or nsd3