Monday, March 16, 2015

domain name system - Editing /etc/hosts




I just signed up for a VPS with Linode, and am going through the beginners' setup instructions, but am a bit lost with the editing for /etc/hosts. It suggests that I edit it as follows (where 12.34.56.78 is my server's ip):



127.0.0.1        localhost.localdomain        localhost
12.34.56.78 something.yourdomain.com something


the file currently reads:



127.0.0.1 localhost


# The following lines are desirable for IPv6 capable hosts
...


First of all, does it matter which of the two localhost lines I use?



Secondly, I don't understand the purpose of the second line - Since the first refers to an IP of 127.0.0.1, I assume these are local addresses, so why would my server's address be of any consequence? Also, I don't presently want any subdomains - should I not include this line, or change it to something else? Does this affect the DNS connection between my domain name and the server?



I'm rather new at this, so I apologize in advance for any silly questions, and thank you for any help you can offer.


Answer




The first line is the loopback, that is, referring back to your own server. This is intrinsic to every computer system.



The second line is to establish which IP the server has been assigned, and which domain the server should serve.



You want to have both lines in the file. You can even have more lines similar to the second one, one for each domain being served.


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