This post will provide an example of the NIS configuration procedures. This will include which packages are needed for a NIS server and client and the procedures for configuration of both server and client.
Setting up a NIS Server
The packages that are required for setting up a NIS Server are:
- ypserv
- ypbind
- portmap
- yp-tools
It is possible to check whether the following packages are installed on the system using the command rpm -q [package-name], e.g.
# rpm -q ypserv ypbind portmap yp-tools
If any of these packages are not installed they can be installed using yum package manager:
# yum install -y ypserv ypbind portmap yp-tools
Perform the following steps to configure the NIS server:
1. The NIS domain needs to be added in /etc/sysconfig/network. Edit the file and add the following line to the end of the file:
# vi /etc/sysconfig/network NISDOMAIN=DOMAIN-NAME
Replace DOMAIN-NAME with the actual domain name of the server, ensure it is in capitals.
2. Execute the command below so that the domain name is set immediately without rebooting system:
# ypdomainname DOMAIN-NAME
3. Verify that it is set correctly:
# ypdomainname DOMAIN-NAME
4. The NIS Server also needs to be set up as a client. Edit the /etc/yp.conf file and add the following line:
# vi /etc/yp.conf ypserver 127.0.0.1
5. Start the daemons NIS needs:
For RHEL3, 4, 5:
# service portmap start # service yppasswdd start # service ypserv start
For RHEL6:
# service rpcbind start # service yppasswdd start # service ypserv start
For RHEL7:
# systemctl start rpcbind # systemctl start yppasswdd # systemctl start ypserv
and ensure they are started on system boot up:
For RHEL3, 4, 5:
# chkconfig portmap on # chkconfig yppasswdd on # chkconfig ypserv on
For RHEL6:
# chkconfig rpcbind on # chkconfig yppasswdd on # chkconfig ypserv on
For RHEL7:
# systemctl enable rpcbind # systemctl enable yppasswdd # systemctl enable ypserv
6. Next, edit /var/yp/Makefile to reflect the following (Don’t merge the passwd file with the shadow file):
# vi /var/yp/Makefile MERGE_PASSWD=false
Ensure to build the shadow file.
all: passwd group hosts rpc services netid protocols mail shadow
7. Generate the NIS database (for 32 bit):
# /usr/lib/yp/ypinit -m
or, for 64-bit installations,
# /usr/lib64/yp/ypinit -m
This command requires the NIS server name to be provided.
8. On RHEL 3, 4 and 5 run the command:
# system-config-authentication
On RHEL 6 and RHEL 7 run the command:
# authconfig --update --nisdomain=your-domain --nisserver=your-server --enablenis
This lets you specify the NIS domain and the NIS server. Enter the domain name as the one which is used previously and localhost as the NIS server.
9. Now start the remaining NIS services:
# service ypbind start # service ypxfrd start # service yppasswdd start
and ensure they are started on system boot
# chkconfig ypbind on # chkconfig ypxfrd on # chkconfig yppasswdd on
On RHEL 7 system, use below commands:
# systemctl start ypbind # systemctl start ypxfrd # systemctl start yppasswdd
# systemctl enable ypbind # systemctl enable ypxfrd # systemctl enable yppasswdd
The above steps complete the steps to configuring a master NIS Server.
Setting up a NIS Client
The following packages are required for setting up a client
- ypbind
- yp-tools
Perform the following steps to configure the NIS client:
1. On RHEL 3,4 and 5 run the command:
# system-config-authentication
On RHEL 6 and RHEL 7 run the command:
# authconfig --update --nisdomain=your-domain --nisserver=your-server --enablenis
This lets you specify the NIS domain and the NIS server. Enter the domain name as the one which is used previously and localhost as the NIS server.
2. Start the ypbind services by executing the following commands:
# chkconfig ypbind on # service ypbind start
On RHEL 7 systems use below commands instead:
# systemctl enable ypbind # systemctl start ypbind
The above procedure is a simple example of setting up an NIS Server and Client. More information can be found at: http://www.linux-nis.org/
Check the user information from NIS Server
Execute the below command to check the user information from the NIS server. This command has to be run from a NIS client machine.
# ypcat passwd
Changing your user password
When you’re using NIS you will need to use the yppasswd command to change your password. Note that the normal passwd command does not change your NIS password.