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 have a VPS which is currently serving 2 websites and a game server. The "primary" website - my website - is robinjam.net.

I've read multiple conflicting tutorials on the internet regarding configuration of hostname, /etc/hosts and DNS, and I'm trying to work out what the "preferred way" of setting this up is.

Can I set my hostname to anything I want?

Do I still need to add my hostname and FQDN to /etc/hosts, even if DNS is resolving my FQDN correctly?

Should the entry in /etc/hosts point to my public IP or the loopback address?

Let's say I want to set the hostname for my VPS to, for example, "linode". Should I add a DNS A record for linode.robinjam.net, or is this unnecessary?

I'm sorry if these are basic questions, but I'm a complete novice when it comes to server administration.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Your hostname can be anything. Generally only sending mail will need a sensible name and/or DNS entry.

The only requirement for your machine to run properly on the network in /etc/hosts is '127.0.01' being opposite 'localhost'

share|improve this answer
    
I thought that might be the case. What about /etc/hosts, which FQDN should I put in there (robinjam.net perhaps)? And does it need to be my public IP or the loopback address? –  robinjam Apr 5 '11 at 15:36
    
You can put your hostname on the same line as localhost for good housekeeping. Locally on the Server you're more concerned with the hostname and localhost. Just let the DNS find your FQDN in most circumstances for simplicity. –  Jonathan Ross Apr 5 '11 at 15:40

You can choose any hostname you want, but consider reading this. No, you don't need to add your hostname or FQDN to /etc/hosts, but it will make some things work in case your DNS server becomes inaccessible. From my experience, it better to add A records for server's hostnames and use CNAME records for all subdomains that corresponds to some services. This will make transition of services from one server to another simplier.

share|improve this answer
1  
You will need an A record for your domain if you want it to be reachable. Service sub-domains (www, pop3, etc.) except email can be handled by CNAME records. –  BillThor Apr 5 '11 at 16:35

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.