Introduction

This page describes how Alexis Huxley installed and configures a NIS master or slave server.

Procedure

  1. This procedure uses some environment variables, so set them:
    NETMASK=<netmask>                                #  E.g. NETMASK=255.255.255.0
    NETWORK=<network-addr>                           #  E.g. NETWORK=192.168.1.0
    NIS_DOMAIN=<nis-domain-name>                     #  E.g. NIS_DOMAIN=pasta.net
  2. To install a NIS master server:
    1. Install the required packages by running:
      apt-get install nis
    2. Work around bug LP#1558196 / BTS#805167 by running:
      systemctl add-wants multi-user.target rpcbind.service

      (PCMS does this for NIS clients, but not for NIS servers.)

    3. Run the following commands:
      echo $NIS_DOMAIN > /etc/defaultdomain
      perl -pi -e "s/^(NISSERVER)=.*/\$1=master/" /etc/default/nis
      {
          echo "255.0.0.0     127.0.0.0"
          echo "$NETMASK      $NETWORK"
      } > /etc/ypserv.securenets
    4. Add support for the auto.staging automounter map by editing /var/yp/Makefile and at the appropriate places adding the following stanzas:
      #  Clone AUTO_HOME variable
      AUTO_STAGING = $(YPSRCDIR)/auto.staging
      
      #   Add this complete line with the other 'ALL += ...' lines
      ALL  += auto.master auto.home auto.staging
      
      #  Clone auto.home recipe
      auto.staging: $(AUTO_STAGING) $(YPDIR)/Makefile
              @echo "Updating $@..."
              -@sed -e "/^#/d" -e s/#.*$$// $(AUTO_STAGING) | $(DBLOAD) \
                      -i $(AUTO_STAGING) -o $(YPMAPDIR)/$@ - $@
              -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@
      
    5. Edit /etc/auto.master to contain only:
      /home    yp:auto.home
      /staging yp:auto.staging
    6. Remove unwanted maps and initialise wanted ones by running something like:
      rm -f /etc/auto.misc
      rm -f /etc/auto.net
      rm -f /etc/auto.smb
      > /etc/auto.home
      > /etc/auto.staging
    7. Populate the following files properly:
      • /etc/passwd
      • /etc/group
      • /etc/auto.home
      • /etc/auto.staging
    8. Compile the maps by running:
      systemctl restart nis             #  make will complain if the service is not running first
      make -C /var/yp
    9. Test by running:
      ypwhich
      domainname
      id alexis
      ypcat auto.home
      su - alexis -c pwd
  3. To install a NIS slave server:
    1. On the master server run:
      perl -pi -e "s/^(NOPUSH)=.*/\$1=false/" /var/yp/Makefile
      echo <name-of-nis-slave-server> | /usr/lib/yp/ypinit -m
    2. On the slave server, install the required packages by running:
      apt-get install nis
    3. Run the following commands:
      echo $NIS_DOMAIN > /etc/defaultdomain
      perl -pi -e "s/^(NISSERVER)=.*/\$1=slave/" /etc/default/nis
      {
          echo "255.0.0.0     127.0.0.0"
          echo "$NETMASK      $NETWORK"
      } > /etc/ypserv.securenets
    4. Run:
      service nis restart
      /usr/lib/yp/ypinit -s <name-of-nis-master-server>
      echo -e '20 *    * * *    root  /usr/lib/yp/ypxfr_1perhour >/dev/null 2>&1\n40 6    * * *    root  /usr/lib/yp/ypxfr_1perday  >/dev/null 2>&1\n55 6,18 * * *    root  /usr/lib/yp/ypxfr_2perday  >/dev/null 2>&1' > /etc/cron.d/nis

See also