Configuring a Fully-Qualified Domain Name (FQDN)

I’ve spent way longer on this than I expected, so I figure I should document it here because I’ll inevitably need it again. This all Ubuntu/Debian specific, so YMMV:

# /etc/hosts
# -------------
# format: IPĀ  FQDN Aliases, comma separated
# list localhost on a line by itself like
127.0.0.1 localhost
# and external ip w/ fqdn and alias
xxx.xxx.0.1 myhost.example.com myhost

# /etc/hostname
# set to _just_ the machine hostname/alias, not fqdn
myhost

Now test with:

username@myhost:~$ hostname -a
myhost
username@myhost:~$ hostname -d
example.com
username@myhost:~$ hostname -f
myhost.example.com

Leave a Reply