1

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.

2 Answers 2

2

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'

2
  • 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?
    – user75046
    Apr 5, 2011 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. Apr 5, 2011 at 15:40
1

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.

1
  • 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, 2011 at 16:35

You must log in to answer this question.