In standard Debian GNU/Linux:

  • the hostname is configured in /etc/hostname as single entry in the first line.

  • the FQDN is configured in /etc/hosts from the first entry found. It must be arranged in the following order:

    IP FQDN hostname
    
  • the domainname is configured as kernel/sysctl parameter: kernel.domainname

By default, the first /etc/hostsentry besides localhost is

127.0.1.1 hostname hostname

which makes things work on personal computers, but does not fit for servers.

Instructions

Summary:

  • find the IPv4 address: ip -4 addr
  • change the 127.0.1.1 line in /etc/hosts to read: IP FQDN hostname
  • create /etc/sysctl.d/10-domainname.conf with content: kernel.domainname=domainname

The correct domainname — which is seldom used — is available after reboot or after sudo sysctl kernel.domainname=domainname

?shnippet:

sudo -i

hostname
hostname -f
domainname
ip -4 addr | awk '/global/{print $2}'

IP=a.b.c.d
DOMAIN=magma-soft.at
HOST=carla

echo $IP $HOST.$DOMAIN $HOST | sudo tee -a /etc/hosts
# put this line to the front and remove 127.0.1.1 in /etc/hosts
sudo editor /etc/hosts

sudo sed w/etc/sysctl.d/10-domainname.conf <<EOF
# $USER $(date -uIs)

kernel.domainname=$DOMAIN
EOF

sudo sysctl kernel.domainname=$DOMAIN