Configure One NIS Master Server That Serves Multiple NIS Domains

Solution Verified - Updated -

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:

  1. Change directory to /var/yp

    # cd /var/yp/
    
  2. Create the first domain

    # ypdomainname domain.one
    
  3. Build the domain subdirectory of /var/yp for the current default domain:

    # /usr/lib64/yp/ypinit -m
    
  4. 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, type ctrl+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.
    
  5. Run ypinit -s nis.example.local on all slave servers.

Now we will create the second domain:

  1. Create the second domain

    # ypdomainname domain.two
    
  2. 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'
    
  3. Use authconfig command to enable NIS and set up the NIS domain one

    # authconfig --update --nisdomain=domain.one --nisserver=127.0.0.1 --enablenis
    
  4. Run ypcat passwd to list all the users and groups in the NIS domain and ypdomainname to show the domain

    # ypcat passwd
    testuser:$6$3Pb/pPZZ$0dx85.l3zYGPsMkgSZChTNcZpfIgSzKmBB75bF8VEsQQBnWZVE/xPR35I74XzvtMRlNy1TQYi/uHeNateRw/O1:1000:1001::/home/testuser:/bin/bash
    
    # ypdomainname 
    domain.one
    
  5. 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
    
  6. Again, Run ypcat passwd to list all the users and groups in the NIS domain and ypdomainname to show the domain

    # ypcat passwd
    testuser:$6$3Pb/pPZZ$0dx85.l3zYGPsMkgSZChTNcZpfIgSzKmBB75bF8VEsQQBnWZVE/xPR35I74XzvtMRlNy1TQYi/uHeNateRw/O1:1000:1001::/home/testuser:/bin/bash
    
    # ypdomainname 
    domain.two
    
  7. 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