I have an Ubuntu server. It is going to be a web server with a URI of
www.example.com. I have a DNS A record pointing
www.example.com to the server's IP address.
Let's say I pick "trinity" as the hostname for this server.
I want to set up the DNS records correctly. I need reverse DNS to
www.example.com, so a CNAME for
www.example.com doesn't seem appropriate. Here's my question:
Is it considered best practice to set up two DNS records (which in my case would likely be two A records), one for
www.example.com and one for
trinity.example.com, both pointing to this server's IP address? (Or, even if it is not accepted as a best practice, is it a good idea?)
If so, would the following be a proper /etc/hosts file?
$ cat /etc/hosts 127.0.1.1 trinity.local trinity 184.108.40.206 trinity.example.com trinity www.example.com
This server is a Linode and Linode's docs seem to imply that the above approach is best (if I am reading them correctly). Here's the relevant section. I bolded the line that seems to apply here.
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 "220.127.116.11" 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."
127.0.0.1 localhost.localdomain localhost 18.104.22.168 plato.example.com plato
The value you assign as your system's FQDN should have an "A" record in DNS pointing to your Linode's IP address. For more information on configuring DNS, please see our guide on configuring DNS with the Linode Manager.