How to make hostname decided by NIS and be fully qualified?
by kaza from LinuxQuestions.org on (#5RGRZ)
Hello!
We have few old servers at work:
Code:uname -a
Linux <old_hostname>.<domain>.local 2.6.9-78.ELsmp #1 SMP Wed Jul 9 15:46:26 EDT 2008 x86_64 x86_64 x86_64 GNU/Linuxwith their hostname being fully qualified. Also we have a NIS server which runs "ypserv"
and each "work" server runs "ypbind".
Recently we added a new server:
Code:uname -a
Linux <new_hostname> 4.18.0-305.el8.x86_64 #1 SMP Thu Apr 29 08:54:30 EDT 2021 x86_64 x86_64 x86_64 GNU/LinuxI added its IP and both short and fully qualified hostnames to the database
of "ypserv", restarted the "ypserv" and now, on each server, if I run
"ypcat hosts | grep <new_hostname>"
I'm getting:
<IP> <new_hostname>.<domainname>.local <new_hostname>
(2 lines, for some reason, both for old and new host names).
but still running "hostname" on the new server gives only the <new_hostnane>,
without the "<domainname>.local"
I searched a lot (and "drowned" in huge number of different answers from different
years for different types of LINUX) and I still can't understand,
in what order RedHat searches what files/services to get the "hostname" result.
The "hosts" line of /etc/nsswitch :
Code:#+hosts: files nis dns myhostname
hosts: nis dnsThe commented line with "+" was the original one, I thought that if I'll remove
other entries I'll force the system to use the "nis" but it didn't produce the
desired result.
The relevant lines of /etc/hosts are:
Code:#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost.localdomain localhost localhost4.localdomain4 localhost4
::1 localhost.localdomain localhost localhost6.localdomain6 localhost6
The commented lines were the original, I changed the order of "full" and "short"
names but again, nothing changed. When I write "nothing changed" I mean: I rebooted
(after each file change) and the same hostname remained.
The contents of /etc/hostname are just the <new_hostname>
The contents of /etc/host.conf are:
multi on
I know I can play with the local files but I would like the correct (and full)
hostname to be taken from the NIS server so that if in future we'll change the domain name,
the change will propagate to all servers.
TIA,
kaza.
We have few old servers at work:
Code:uname -a
Linux <old_hostname>.<domain>.local 2.6.9-78.ELsmp #1 SMP Wed Jul 9 15:46:26 EDT 2008 x86_64 x86_64 x86_64 GNU/Linuxwith their hostname being fully qualified. Also we have a NIS server which runs "ypserv"
and each "work" server runs "ypbind".
Recently we added a new server:
Code:uname -a
Linux <new_hostname> 4.18.0-305.el8.x86_64 #1 SMP Thu Apr 29 08:54:30 EDT 2021 x86_64 x86_64 x86_64 GNU/LinuxI added its IP and both short and fully qualified hostnames to the database
of "ypserv", restarted the "ypserv" and now, on each server, if I run
"ypcat hosts | grep <new_hostname>"
I'm getting:
<IP> <new_hostname>.<domainname>.local <new_hostname>
(2 lines, for some reason, both for old and new host names).
but still running "hostname" on the new server gives only the <new_hostnane>,
without the "<domainname>.local"
I searched a lot (and "drowned" in huge number of different answers from different
years for different types of LINUX) and I still can't understand,
in what order RedHat searches what files/services to get the "hostname" result.
The "hosts" line of /etc/nsswitch :
Code:#+hosts: files nis dns myhostname
hosts: nis dnsThe commented line with "+" was the original one, I thought that if I'll remove
other entries I'll force the system to use the "nis" but it didn't produce the
desired result.
The relevant lines of /etc/hosts are:
Code:#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost.localdomain localhost localhost4.localdomain4 localhost4
::1 localhost.localdomain localhost localhost6.localdomain6 localhost6
The commented lines were the original, I changed the order of "full" and "short"
names but again, nothing changed. When I write "nothing changed" I mean: I rebooted
(after each file change) and the same hostname remained.
The contents of /etc/hostname are just the <new_hostname>
The contents of /etc/host.conf are:
multi on
I know I can play with the local files but I would like the correct (and full)
hostname to be taken from the NIS server so that if in future we'll change the domain name,
the change will propagate to all servers.
TIA,
kaza.