Set a fully qualified domain name (FQDN) hostname on your server

No matter your server is a testing machine or production server, it’s strongly recommended to set a fully qualified domain name (FQDN) hostname.

Enter command hostname -f to view the current hostname:

$ hostname -f
mx.example.com

On Debian/Ubuntu Linux, hostname is set in two files: /etc/hostname and /etc/hosts.

  • /etc/hostname: short hostname, not FQDN.
mx
  • /etc/hosts: static table lookup for hostnames. Warning: Please list the FQDN hostname as first item.
# Part of file: /etc/hosts
127.0.0.1   mx.example.com mx localhost localhost.localdomain

Verify the FQDN hostname. If it wasn’t changed after updating above two files, please reboot server to make it work.

$ hostname -f
mx.example.com

Leave a Reply

Your email address will not be published. Required fields are marked *