In standard Debian GNU/Linux:
the hostname is configured in
/etc/hostnameas single entry in the first line.the FQDN is configured in
/etc/hostsfrom the first entry found. It must be arranged in the following order:IP FQDN hostnamethe
domainnameis configured as kernel/sysctlparameter: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.1line in/etc/hoststo read:IP FQDN hostname - create
/etc/sysctl.d/10-domainname.confwith 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