NIS on Solaris

NIS on Solaris 10u5

Overview

For more information see NIS Setup and Administration

Setup

YP Master Server

 1. Create a directory for the NIS source files
# mkdir /etc/yp
 2. Update /var/yp/Makefile DIR, PWDIR, RBACDIR, INETDIR and ALIASES variables with the above path
# vi /var/yp/Makefile
 # Set the following variable to "-b" to have NIS servers use the domain name
 # resolver for hosts not in the current domain.
 B=-b
 #B=

 DIR=/etc/yp
 PWDIR=/etc/yp
 INETDIR=/etc/yp
 RBACDIR=/etc/yp
 ALIASES = /etc/yp/aliases

 # Edit this line to exclude/include the necesary maps
all: passwd group hosts ipnodes ethers networks rpc services protocols \
        netgroup bootparams aliases publickey netid netmasks c2secure \
        timezone auto.master auto.home ageing \
        auth.attr exec.attr prof.attr user.attr audit.user
 3. Copy the necessary source files (among the following aliases, auto.home or auto_home, auto.master or auto_master, bootparams, ethers, group, hosts, ipnodes, netgroup, netmasks, networks, passwd, protocols, publickey, rpc, service, shadow, timezone, user_attr, audit_user, auth_attr, exec_attr, and prof_attr) in /etc/yp
# vi /etc/timezone
 Europe/Moscow   <NIS_domain>
 4. Clean all comments and other extraneous lines and information from the source files. These operations can be done through a sed or awk script or with a text editor. The Makefile performs some file cleaning automatically for you, but it is good practice to examine and clean these files by hand before running. 
 5. Add IP addresses on NIS slave servers into /etc/hosts file. Configure NIS domain name then run ypinit to convert source files into dbm files.
# vi /etc/hosts
 192.168.0.1 nis_server1.domain.com nis_server1
 192.168.0.2 nis_server2.domain.com nis_server2

# vi /etc/defaultdomain
 <NIS_domain>

# domainname <NIS_domain>

# ypinit -m
 6. Start NIS server (and NIS client)
# svcadm enable nis/server
# svcadm enable nis/client
 7. Edit /etc/nsswitch.conf. Append "nis" to the services that should use NIS resolution
# vi /etc/nsswitch.conf
 passwd:     files nis
 group:      files nis
 netmasks:   files nis
 publickey:  files nis
 automount:  files nis
 aliases:    files nis

YP Slaver Server

 1. Setup NIS domain and add NIS servers in /etc/hosts
# vi /etc/defaultdomain
 <NIS_domain>

# domainname <NIS_domain>

# vi /etc/hosts
 192.168.0.1 nis_server1.domain.com nis_server1
 192.168.0.2 nis_server2.domain.com nis_server2
 2. Initialize NIS client and enable NIS client service
# ypinit -c
 nis_server1.domain.com
 nis_server2.domain.com

# svcadm enable nis/client
 3. Initialize NIS slave and ensure that NIS server is running
# ypinit -s nis_server1
# svcs nis/server
STATE          STIME    FMRI
online         11:25:57 svc:/network/nis/server:default
 4. Edit /etc/nsswitch.conf. Append "nis" to the services that should use NIS resolution
# vi /etc/nsswitch.conf
 passwd:     files nis
 group:      files nis
 netmasks:   files nis
 publickey:  files nis
 automount:  files nis
 aliases:    files nis

YP clients

 1. Setup domain name and add NIS servers into the /etc/hosts file
# vi /etc/defaultdomain
 <NIS_domain>

# domainname <NIS_domain>

# vi /etc/hosts
 192.168.0.1 nis_server1.domain.com nis_server1
 192.168.0.2 nis_server2.domain.com nis_server2
 2. Initialize the client and start the NIS service
# ypinit -c
# svcadm nis/client
 3. Edit /etc/nsswitch.conf. Append "nis" to the services that should use NIS resolution
# vi /etc/nsswitch.conf
 passwd:     files nis
 group:      files nis
 netmasks:   files nis
 publickey:  files nis
 automount:  files nis
 aliases:    files nis

# vi /etc/auto_master
/home           auto_home       -restrict,nosuid,nobrowse

# vi /etc/auto_home
#+auto_home
+auto.home

# svcadm disable autofs
# svcadm enable autofs
 4. For fine permission tuning, one may use compat value for passwd field in /etc/nsswitch.conf, and then add entries such as +|-[NIS_username|@NIS_groupname]: in both /etc/passwd and /etc/shadow to allow or forbid certain NIS users or groups.

Administering NIS servers

 1. To modify a NIS map, edit the source file and rebuild the map; for example,
# vi /etc/yp/auto_home
 <username> <nfs_server>:/export/home/&

# cd /var/yp
# make auto.home