Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am a little confused about the hosts file in Linux, and what I have to set in it. I am setting up an email server which is on our gateway. Now this machine obviously has an internal and external IP address. What hostname do I give this machine?

E.g. there is a website behind this machine, and the website is exampledomain.com Do I make up a hostname such as gw.exampledomain.com and assign that to the hosts file?

share|improve this question
    
You appear a little confused. The hosts file is completely unrelated to the host name. If you want to avoid problems leave that file alone unless you have an absolute need to change it and fully understand the consequences of doing so. –  John Gardeniers Aug 29 '12 at 7:03

2 Answers 2

If you mean the host name that shows up in the command prompt, then you can freely choose any name that indicates to you on which server you are working now.

If you mean the names listed in the hosts file, you need to have at least the chosen host name of the local machine in this file. This is sometimes used by some programs/services. So, it is recommended to have a valid one. Otherwise, things may slow down.

share|improve this answer

The hosts file found in /etc/hosts in linux is used in the absense of a name server.Any kind of network program on your machine will consult this file to determine the IP address that maps to a host name.The hostname is maintained by the kernel and domain name is determined by hosts file or via DNS.So you can choose any hostname for your machine.

So if you have a DNS server then you dont need to add anything in the host file.For more details take a look at:- http://www.faqs.org/docs/securing/chap9sec95.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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