LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-04-2021, 08:39 AM   #1
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 343

Rep: Reputation: 2
How to make hostname decided by NIS and be fully qualified?


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/Linux
with 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/Linux
I 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 dns
The 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.
 
Old 11-07-2021, 10:39 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,150

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
What is NISDOMAIN set to?

How is the NIS server found? By DNS?
 
Old 11-08-2021, 12:39 AM   #3
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,806

Rep: Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207
The command
hostname
prints a locally defined hostname.
Consider the following commands for more details:
Code:
hostname -s
hostname -f
hostname -i
hostnamectl
Check the files /etc/hosts and /etc/hostname

You should have files before nis in /etc/nsswitch.conf, otherwise during booting there is malfunction/timeout when NIS client did not yet bind. And too many timeouts when the NIS server is down.

The command
ypcat hosts
prints from the NIS server's DB. The DB is usually built from a source file with a make command.

Last edited by MadeInGermany; 11-08-2021 at 12:41 AM.
 
Old 11-13-2021, 03:26 PM   #4
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 343

Original Poster
Rep: Reputation: 2
Hi, thanks for the answers.

So, if I understand correctly, it's absolutely doesn't matter what the NIS server calls some particular server,
the "hostname" command is ALWAYS governed by the local files?

TIA,
kaza.
 
Old 11-14-2021, 05:18 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,806

Rep: Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207
Usually the NIS hosts are like the DNS hosts, give global information about all the hosts.
And usually the order is files then nis, so /etc/hosts /etc/hostname hostnamectl are considered for the own hostname.
The resulting hostnames can be listed with
Code:
getent hosts
that usually works like
Code:
cat /etc/hosts; ypcat hosts
A particular hostname lookup can be tested with
Code:
getent hosts <hostname>
getent hosts <ip address>
That searches through /etc/hosts
then does a hash lookup
Code:
ypmatch <hostname> hosts.byname
yomatch <ip address> hosts.byaddr
The available NIS maps on the NIS server are shown with
Code:
ypwhich -m
Note that NIS is very old, does not cache results, does not provide safety against "illegal" hosts so should be restricted to "safe" networks.
BTW a separate old service nscd (name service caching daemon) was developed for caching NIS lookups. It also caches other naming services like LDAP, but conflicts with modern services like sssd.

Last edited by MadeInGermany; 11-14-2021 at 05:38 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
squid FATAL: Could not determine fully qualified hostname. Please set 'visible_hostn tarakthakor Linux - Networking 5 12-04-2010 05:29 AM
hostname and fully qualified domain name setup help strimp099 Linux - Networking 7 01-14-2005 10:07 PM
squid fully qualified hostname DutchBoy Linux - Software 2 09-08-2004 10:17 PM
Fully qualified hostname gubak Linux - Newbie 8 07-23-2004 11:56 PM
need fully qualified hostname before log-in - how? BrianK Linux - Networking 7 03-12-2002 06:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration