Detailed steps for setting up and configuring nis domain services on Centos8

Detailed steps for setting up and configuring nis domain services on Centos8

Introduction to NIS

NIS, the full name in English is network information service, also called yellow pages. In Linux, NIS is an RPC-based client/server system that requires the use of RPC services.

RPC stands for Remote Procedure Call Protocol. RPCBIND is used to replace the portmap component in the old version. Simply put, RPCBIND is used to bind different services to corresponding ports in order to support interoperability between machines.

Network environment:

node Host
node1 (nis master server) 192.168.10.222
node2 (nis client) 192.168.10.223

1. Environment preparation (both nodes are required)

Turn off firewall

systemctl stop firewalld 
setenforce 0

Add hostname resolution

vim /etc/hosts
192.168.10.222 node1 
192.168.10.223 node2

2.nis master server configuration

Download the package

yum -y install rpcbind ypserv ypbind yp-tools 

Add nis domain name

[root@localhost ~]# nisdomainname skills.com 
vim /etc/sysconfig/network
NISDOMAIN skills.com

Automatically mount the nis domain name at boot time

[root@localhost ~]# vim /etc/rc.d/rc.local
 touch /var/lock/subsys/local
/bin/nisdomainname skills.com
[root@localhost ~]# chmod 777 /etc/rc.d/rc.local

Modify the main configuration file to restrict permissions

vim /etc/ypserv.conf
192.168.10.0/24:*:*:none //Give access rights to this network segment 192.168.10.222:*:*:none //Give access rights to this local machine:*:*:deny //Reject other servers

Restart the service

systemctl restart yppasswdd rpcbind ypserv 
systemctl enable yppasswdd rpcbind ypserv

Create a database

[root@localhost ~]# /usr/lib64/yp/ypinit -m
 
At this point, we have to construct a list of the hosts which will run NIS
servers. localhost is in the list of NIS server hosts. Please continue to add
the names for the other hosts, one per line. When you are done with the
list, type a <control D>.
        next host to add: localhost
        next host to add:  
The current list of NIS servers looks like this:
 
localhost
 
Is this correct? [y/n: y] y
We need a few minutes to build the databases...
Building /var/yp/skills.com/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory '/var/yp/skills.com'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating hosts.byname...
Updating hosts.byaddr...
Updating rpc.byname...
Updating rpc.bynumber...
Updating services.byname...
Updating services.byservicename...
Updating netid.byname...
Updating protocols.bynumber...
Updating protocols.byname...
Updating mail.aliases...
gmake[1]: Leaving directory '/var/yp/skills.com'
 
localhost has been set up as a NIS master server.
 
Now you can run ypinit -s localhost on all slave servers.
[root@localhost ~]#

Create a new nis account

useradd nis1 -p123 
useradd nis2 -p123 
When the host changes, cd to /var/yp make 
[root@localhost ~]# cd /var/yp/
[root@localhost yp]# make
gmake[1]: Entering directory '/var/yp/skills.com'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating netid.byname...
gmake[1]: Leaving directory '/var/yp/skills.com'
[root@localhost yp]#

Restart the service

systemctl restart yppasswdd rpcbind ypserv 
systemctl enable yppasswdd rpcbind ypserv

3.nis client settings

Download the package

yum -y install ypbind rpcbind yp-tools

Add nis domain name

[root@localhost ~]# nisdomainname skills.com 
vim /etc/sysconfig/network
NISDOMAIN skills.com

Automatically mount the nis domain name at boot time

[root@localhost ~]# vim /etc/rc.d/rc.local
 touch /var/lock/subsys/local
/bin/nisdomainname skills.com
[root@localhost ~]# chmod 777 /etc/rc.d/rc.local

Edit the yp.conf file and set the main service.

domain skills.com server 192.168.10.222

Restart the service

 systemctl restart ypbind rpcbind

yptest to see if the joining is successful

[root@localhost ~]# yptest
Test 1: domainname
Configured domainname is "skills.com"
 
Test 2: ypbind
Use Protocol V1: Used NIS server: 192.168.10.222
Use Protocol V2: Used NIS server: 192.168.10.222
Use Protocol V3:
ypbind_nconf:
        nc_netid: udp
        nc_semantics: 1
        nc_flag: 1
        nc_protocol: 'inet'
        nc_proto: 'udp'
        nc_device: '-'
        nc_nlookups: 0
ypbind_svcaddr: 192.168.10.222:740
ypbind_servername: 192.168.10.222
ypbind_hi_vers: 2
ypbind_lo_vers: 2
 
Test 3: yp_match
WARNING: No such key in map (Map passwd.byname, key nobody)
 
Test 4: yp_first
nis1 nis1:123:1000:1000::/home/nis1:/bin/bash
 
Test 5: yp_next
nis2 nis2:123:1001:1001::/home/nis2:/bin/bash
 
Test 6: yp_master
localhost
 
Test 7: yp_order
1639387530
 
Test 8: yp_maplist
netid.byname
group.bygid
group.byname
passwd.byuid
passwd.byname
mail.aliases
protocols.byname
protocols.bynumber
services.byservicename
services.byname
rpc.bynumber
rpc.byname
hosts.byaddr
hosts.byname
ypservers
 
Test 9: yp_all
nis1 nis1:123:1000:1000::/home/nis1:/bin/bash
nis2 nis2:123:1001:1001::/home/nis2:/bin/bash
1 tests failed
[root@localhost ~]#

Configuring Domain User Login

[root@localhost ~]# authselect select nis --force
Backup stored at /var/lib/authselect/backups/2021-12-13-09-34-52.8NFKZD
Profile "nis" was selected.
The following nsswitch maps are overwritten by the profile:
- aliases
-automount
- ethers
- group
- hosts
- initgroups
-netgroup
- networks
-passwd
- Protocols
-publickey
-rpc
- services
-shadow
 
Make sure that NIS service is configured and enabled. See NIS documentation for more information.
 
[root@localhost ~]#

Configure nfs on the primary server to share the home directory.

[root@localhost yp]# vim /etx/exports
/home/ *(rw,sync)
[root@localhost yp]# exportfs -rv
exporting *:/home

The client mounts the home directory of the primary server

systemctl restart nfs-server 
[root@localhost ~]# mount 192.168.10.222:/home/ /home/
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 379852 0 379852 0% /dev
tmpfs 399816 0 399816 0% /dev/shm
tmpfs 399816 5688 394128 2% /run
tmpfs 399816 0 399816 0% /sys/fs/cgroup
/dev/mapper/cl-root 17811456 1615988 16195468 10% /
/dev/sda1 1038336 196688 841648 19% /boot
/dev/sr0 9046654 9046654 0 100% /media
tmpfs 79960 0 79960 0% /run/user/0
192.168.10.222:/home 17811456 1644672 16166784 10% /home
[root@localhost ~]#

Add the function of automatically mounting the main service home directory at startup.

vim /etc/fstab
192.168.10.222:/home /home nfs defaults 0 0
[root@localhost ~]# mount -a 
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 379852 0 379852 0% /dev
tmpfs 399816 0 399816 0% /dev/shm
tmpfs 399816 5688 394128 2% /run
tmpfs 399816 0 399816 0% /sys/fs/cgroup
/dev/mapper/cl-root 17811456 1613680 16197776 10% /
/dev/sda1 1038336 196688 841648 19% /boot
/dev/sr0 9046654 9046654 0 100% /media
192.168.10.222:/home 17811456 1644544 16166912 10% /home
tmpfs 79960 0 79960 0% /run/user/0
[root@localhost ~]#

At this point, the nis configuration is complete.

This is the end of this article about the detailed steps of setting up and configuring nis domain services on Centos8. For more information about setting up nis domain services on Centos8, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed process of configuring NIS in Centos7

<<:  A general method for implementing infinite text carousel with native CSS

>>:  uniapp Sample code for implementing global sharing of WeChat mini-programs

Recommend

Vue3 list interface data display details

Table of contents 1. List interface display examp...

Detailed explanation of Vue custom instructions

Table of contents Vue custom directive Custom dir...

Solve the problem of invalid utf8 settings in mysql5.6

After the green version of mysql5.6 is decompress...

How to implement element floating and clear floating with CSS

Basic Introduction to Floating In the standard do...

mysql delete multi-table connection deletion function

Deleting a single table: DELETE FROM tableName WH...

Vite+Electron to quickly build VUE3 desktop applications

Table of contents 1. Introduction 2. Create a Vit...

Detailed steps to install web server using Apache httpd2.4.37 on centos8

Step 1: yum install httpd -y #Install httpd servi...

Example code for implementing equal width layout in multiple ways using CSS

The equal-width layout described in this article ...

Mysql NULL caused the pit

Using NULL in comparison operators mysql> sele...

Solution to the problem that input in form cannot be submitted when disabled

I wrote a test program before, in which adding and...

Linux uses if to determine whether a directory exists.

How to use if in Linux to determine whether a dir...

CentOS 8.0.1905 installs ZABBIX 4.4 version (verified)

Zabbix Server Environment Platform Version: ZABBI...

Example of how to configure multiple virtual hosts in nginx

It is very convenient to configure virtual host v...