Recently I setup logcheck, but found it was sending email reports purporting to be from
localhost, which is absolutely useless for anyone trying to manage multiple servers (aren't we all)!
Digging into the cause, I found logcheck gets the local hostname by using either
hostname --short or
hostname --fqdn, depending on the value of
FQDN found in
/etc/logcheck/logcheck.conf. Since my config had
FQDN=1, I was able to replicate the trouble I was experiencing with logcheck reports by running the
hostname --fqdn command.
Long story short, my
/etc/hosts was to blame. I had picked up a bad habit. Maybe I picked it up from old windows hosts files which list each entry on a separate line. Reading TFM for
/etc/hosts, I found the following:
This file is a simple text file that associates IP addresses with hostnames, **one line per IP address**. For each host a single line should be present with the following information: IP_address canonical_hostname [aliases...]
My file had improperly been setup with:
127.0.0.1 localhost some.example.com 127.0.0.1 another.alias
Which is wrong in two ways.
- The canonical hostname is out of place.
- There must only be one line for each IP.
Here's a corrected example:
127.0.0.1 some.example.com localhost another.alias
By fixing that, I no longer get
localhost when I run
hostname --fqdn and now get the desired fully qualified domain name of