What is proper relationship between /etc/hosts and DNS A records for a Linux server?

Solution 1:

The proper relationship between /etc/hosts entries and DNS is that if you have working DNS /etc/hosts should only contain entries for localhost (pointing to 127.0.0.1 and ::1). Mucking about with a hosts file when you have working DNS is just a way to create strange behavior and trouble later.1

If you need reverse DNS contact your ISP (Linode) and ask them to set an appropriate PTR record for your IP address.
There is no requirement for the PTR record to match an A record (or indeed for any host with that name to exist at all: 69.18.136.215 reverses to cl136-215.invision.net, which does not have a forward address), so you can set the PTR name to match an A record, a CNAME, or to any valid DNS name you would like.


1As with all rules, exceptions exist. Your case does not sound like one of them.

Solution 2:

In your system setup, the /etc/hosts file is probably read before resorting to DNS lookups. So I'd probably provide the systems's IP, fully-qualified domain name (trinity.example.com), the short name (trinity) and the website address (www.example.com).

Here's a guide for the format of your hosts file. See: Setting the hostname: FQDN or short name?

Solution 3:

If you put those entries in the /etc/hosts file your system will bypass DNS and use the entry from the hosts file.
This could complicate the debugging if something in one of these configs (DNS or hosts file) is wrong. Or you have strange behaviours if you change the DNS records and forget the /etc/hosts file.

You can use the /etc/hosts file for testing purposes, for example testing your site before DNS changes are made.