The Public web server should use the Public DNS. If possible, you want the web server in a DMZ. Depending on how your network addressing is done, you may want the external name pointing to the internal IP address on the internal IP address. The Public DNS should have the IP address required to access the server from the Internet. If you use NAT or a proxy, this may not be the address of the web server.
Unless you want the Database server accessible from the Internet, it should be on the internal network and use the internal DNS. It is relatively rare that you would want the server accessible from the Internet. Depending on the contents, their may be obligations to secure the database against access from the Internet.
The value of the /etc/hostname
can be whatever you want, but should be an internal name. It is common to have services with their own name which is distinct from the name of the host on which they run. Separating the service name from the host name facilitates moving or scaling the service.
If you add the addresses to /etc/hosts
use the internal DNS addresses. Anything in this file should be the same value as the host would get from DNS. Unless your internal DNS is unreliable, it should not be necessary to include the addresses there. In my case I use dnsmasq
as my internal DNS, and it is configured from a hosts
file. This makes it very easy to have one true source
for IP addresses.
If you do put the addresses in the hosts file, try to automate the update so you don't have to edit every servers file manually. Manual edits tend to be error prone, and you want to do as few as possible.