I'm hitting related issues right now running 22.03.5 and I can with impunity say that it sets the hostname only.
You can verify this with cat /proc/sys/kernel/hostname
and cat /proc/sys/kernel/domainname
AFAIK, the correct way to set the domainname is to make a file in /etc/sysctl.d/
This is a fairly fundamental setting so I called it 01-domainname.conf (they are executed in the listed, alphanumeric, order.)
Contents of the file should be:
kernel.domainname=<yourdomainname>
No quotes around the yourdomainname.
Then run /etc/sysctl restart
and cat /proc/sys/kernel/domainname
again to verify.
Now the domain is set in the kernel.
I didn't see a way to install inetutils to get the hostname utility so here's a script that mimic's it. (Put in /usr/bin and chmod +x /usr/bin/hostname
so it can execute.)
#!/bin/sh
fqdn=0
domainonly=0
while getopts 'dfs' c; do
case $c in
d) domainonly=1 ;;
s) fqdn=0 ;;
f) fqdn=1 ;;
*)
printf "%s [-dfs] \n" "$0"
printf "Options:\n"
printf "\t-d: DNS domain name\n"
printf "\t-s: \"short\", hostname only\n"
printf "\t-f: FQDN\n"
exit
;;
esac
done
if [ "$domainonly" != "0" ]; then
cat /proc/sys/kernel/domainname
elif [ "$fqdn" != "0" ]; then
printf "%s.%s\n" "$(cat /proc/sys/kernel/hostname)" "$(cat /proc/sys/kernel/domainname)"
else
cat /proc/sys/kernel/hostname
fi