Configure One NIS Master Server That Serves Multiple NIS Domains
Environment
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
Issue
- Setup a single NIS master for 2 domains
Resolution
First Domain
To begin, we will create the first Domain:
-
Change directory to
/var/yp
# cd /var/yp/
-
Create the first domain
# ypdomainname domain.one
-
Build the domain subdirectory of /var/yp for the current default domain:
# /usr/lib64/yp/ypinit -m
-
When
ypinit
prompts for a list of other machines to become NIS slave servers, type the name of the server you are working on, along with the names of your NIS slave servers, one per line. When you are done with the list, typectrl+D
.next host to add: nis.example.local next host to add: The current list of NIS servers looks like this: nis.example.local Is this correct? [y/n: y] y We need a few minutes to build the databases... Building /var/yp/domain.one/ypservers... Running /var/yp/Makefile... gmake[1]: Entering directory `/var/yp/domain.one' 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/domain.one' nis.example.local has been set up as a NIS master server.
-
Run
ypinit -s nis.example.local
on all slave servers.
Now we will create the second domain:
-
Create the second domain
# ypdomainname domain.two
-
Update the NIS configuration to map DOM=domain.two using the
make
command# make DOM=domain.two gmake[1]: Entering directory `/var/yp/domain.two' 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/domain.two'
-
Use
authconfig
command to enable NIS and set up the NIS domain one# authconfig --update --nisdomain=domain.one --nisserver=127.0.0.1 --enablenis
-
Run
ypcat passwd
to list all the users and groups in the NIS domain andypdomainname
to show the domain# ypcat passwd testuser:$6$3Pb/pPZZ$0dx85.l3zYGPsMkgSZChTNcZpfIgSzKmBB75bF8VEsQQBnWZVE/xPR35I74XzvtMRlNy1TQYi/uHeNateRw/O1:1000:1001::/home/testuser:/bin/bash # ypdomainname domain.one
-
Use
authconfig
command again to enable NIS and set up the NIS domain two# authconfig --update --nisdomain=domain.two --nisserver=127.0.0.1 --enablenis
-
Again, Run
ypcat passwd
to list all the users and groups in the NIS domain andypdomainname
to show the domain# ypcat passwd testuser:$6$3Pb/pPZZ$0dx85.l3zYGPsMkgSZChTNcZpfIgSzKmBB75bF8VEsQQBnWZVE/xPR35I74XzvtMRlNy1TQYi/uHeNateRw/O1:1000:1001::/home/testuser:/bin/bash # ypdomainname domain.two
-
Success!
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments