1
1
I have never been able to fully understand how to change Linux hostname and domainname, and now it comes back and bites me again -- my Linux domainname is blank (domainname
gives (none)
) and I just cannot change it back:
$ hostname
coral
$ hostname -f
coral
$ hostname -d
$ hostname -d | wc
0 0 0
$ domainname
(none)
$ dnsdomainname
$ dnsdomainname | wc
0 0 0
$ cat /etc/hostname
coral
$ head -1 /etc/hosts
127.0.0.1 localhost.my.domain.org localhost
$ cat /etc/resolv.conf
# Fixed resolv.conf file
domain my.domain.org
search my.domain.org
nameserver 192.168.2.102
$ time dig coral
;; ANSWER SECTION:
coral. 0 IN A 192.168.2.102
real 0m0.038s
user 0m0.032s
sys 0m0.004s
I've rebooted several times, and my domainname is still blank now. The above is after several reboots.
Adding more details.
- Using alias the host name in
/etc/hosts
to specific the FQDN seems to be the correct answer, however, I've already done that see the abovelocalhost.my.domain.org
entry. I didn't put my host name (coral) in/etc/hosts
because I don't want my host name to resolve to127.0.0.1
but to real IP instead, which I obtained from my DNS server. - I did a trace on
hostname -f
, but can't figure any problem out of the log. I can put it here if anyone interested.
As a consequence, there is an extensive (network) delay to start and stop my sendmail server.
UPDATE:
Today, the hostname -f
, hostname -d
& dnsdomainname
are all working fine now. I didn't do anything, except I traced again the hostname -f
. I should have traced to a new file, but I didn't. So now it is working, and I still do not know why it is working now, and why it didn't work before. Moreover, even when everything is working, my sysctl kernel.domainname
is still reporting (none)
. This is so strange and convoluted.
$ uptime
21:33:36 up 2 days, 1:36, 5 users, load average: 0.22, 0.43, 0.29
$ sysctl kernel.domainname
kernel.domainname = (none)
And the above (network) delay to connecting to my sendmail server is gone too. So my conclusion is that all I was doing above was correct, but somehow it mystically take a great amount of time for my Ubuntu 17.04 to realized it.
Anyway, I'll accept JakeGould's answer as he has something new in how to use sysctl
and kernel.hostname
.
Thank you all who helped!
2
Don't worry about
– Bob – 2017-05-30T00:23:12.627domainname
unless you're a time traveler from the 90s. I also generally wouldn't worry aboutdnsdomainname
- it's generally unimportant and should not affect network performance.No, domainname is part of the FQDN (Fully Qualified Domain Name) that my sendmail mail server depends on. – xpt – 2017-05-30T03:52:59.980
2
domainname
has nothing to do with a FQDN. Its only relevance is an old pre-LDAP system that hasn't been used in 20 years. Whilednsdomainname
is more relevant, it still should not result in any performance issues. If name resolution is taking a long time, that's more likely because of misconfigured or slow resolvers (/etc/resolv.conf
) or possibly a lacking entry for resolving your own hostname. – Bob – 2017-05-30T05:06:19.437@Bob, my OP updated, showing that
/etc/resolv.conf
is not the problem and there is no DNS resolve delay. Again my sendmail mail server depends on FQDN, and when it is not matching with what system thinks, it will cause extensive delay. It has always been the case for me. And this is a home Linux system that do not use LDAP but pure DNS server. – xpt – 2017-05-30T12:53:18.060@Bob is very relevant:
– Pablo A – 2019-09-25T21:12:45.567curl -v verysecuresite.com
fetch data because DNS server receive "verysecuresite.com.utopia.net". On a systemd distrosysctl kernel.domainname
return(none)
andhostname -d
nothing.systemd-resolve --status
returnutopia.net
on fieldDNS Domain:
, onGlobal
and on an interface. The utopia thing comes from an ISP hijacked router (OPTION: 15 ( 10) Domainname utopia.net
ondhcpdump
). I removed from the interface (systemd-resolve --set-domain=local --interface=eth0
) but not yet from Global.