Slackware-NIS-mini-HOWTO How to set up a NIS server and configure NIS clients on Slackware Linux 14-Dec-2000 David Cantrell :/export/home Of course, replace with the hostname of your NFS/NIS server. STEP 6: Edit the NFS exports file on the server ------------------------------------------------ Now we need to make sure that /export is shared from the server. Edit /etc/exports and make sure this line is present: /export (rw,no_root_squash) Save the file and restart the NFS server daemons: killall -HUP rpc.nfsd rpc.mountd STEP 7: Pick a name for your NIS domain ---------------------------------------- Each NIS domain needs to have a unique name. Do not use the same name as your DNS domain. This should be something different. I will use "mynis" in this example. Edit /etc/defaultdomain and add the name of your NIS domain: mynis Save and exit. The name of your NIS domain shoulw be the only thing in that file. Once you've done that, set the NIS domain with this command: nisdomainname `cat /etc/defaultdomain` STEP 8: Edit /var/yp/Makefile ------------------------------ The NIS server has a Makefile that controls what maps are served out by NIS. Each time you make a change (such as adding a user), you should go into /var/yp and type "make" to update the NIS information. In this file we need to edit the all: target and specify the stuff we want to share. Here's what your all: target should look like: all: passwd group hosts rpc services netid protocols netgrp mail \ shadow auto.master auto.export Now find the line that looks like this: AUTO_LOCAL = $(YPSRCDIR)/auto.local We want to add this line just after that line: AUTO_EXPORT = $(YPSRCDIR)/auto.export Now find the auto.local: target. We need to add this target just after that target: auto.export: $(AUTO_EXPORT) $(YPDIR)/Makefile @echo "Updating $@..." -@sed -e "/^#/d" -e s/#.*$$// $(AUTO_EXPORT) | $(DBLOAD) \ -i $(AUTO_EXPORT) -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ Save the Makefile and exit. STEP 9: Edit /var/yp/securenets -------------------------------- Edit /var/yp/securenets and change the "0.0.0.0 0.0.0.0" line to something like this: 255.255.255.0 192.168.1.0 You should specify your network address and submask there, this is only an example. This example restricts NIS access to any machine on the 192.168.1 class C subnet. STEP 10: Create an /etc/ypserv.conf file ----------------------------------------- The only line you need in this file is: dns: yes This line tells ypserv to resolve hostnames using a DNS server instead of relying on NIS hostname maps (which you probably aren't using). Save and exit. STEP 11: Start ypbind ---------------------- Start ypbind: /usr/sbin/ypbind Use ps to make sure it started and is running properly. You will probably see a master and slave process for it. STEP 12: Start ypserv ---------------------- Start ypserv: /usr/sbin/ypserv Use ps to make sure it started and is running properly. STEP 13: Initialize the NIS maps --------------------------------- We need to initialize the NIS maps with this command: /usr/lib/yp/ypinit -m Fill in the blanks for all machines on your network that will be acting as NIS servers. At this point, you probably want to fire up rpc.yppasswdd to make sure that users on NIS clients can run chfn and passwd. STEP 14: Done, making sure NIS stuff loads at bootup ----------------------------------------------------- Your NIS server is now up and running. You should edit /etc/rc.d/rc.inet2 and make sure the following block is uncommented: # Setting up NIS: # (NOTE: For detailed information about setting up NIS, see the documentation # in /usr/doc/yp-tools, /usr/doc/ypbind, and /usr/doc/ypserv) # # First, we must set the NIS domainname. NOTE: this is not # necessarily the same as your DNS domainname, set in # /etc/resolv.conf! The NIS domainname is the name of a domain # served by your NIS server. if [ -r /etc/defaultdomain ]; then nisdomainname `cat /etc/defaultdomain` fi # Then, we start up ypbind. It will use broadcast to find a server. if [ -d /var/yp ] ; then echo -n " ypbind" ${NET}/ypbind fi # If you are the NIS master server for the NIS domain, then # you must run rpc.yppasswdd, which is the RPC server that # lets users change their passwords. if [ -x ${NET}/rpc.yppasswdd ]; then echo -n " yppasswdd" ${NET}/rpc.yppasswdd fi It's probably adviseable to run rpc.yppasswdd with this line: ${NET}/rpc.yppasswdd -e chsh -e chfn This ensures that chfn and chsh work. You also need to add this after the ypbind if block: if [ -x ${NET}/ypserv ]; then echo -n " ypserv" ${NET}/ypserv fi The ypserv program needs to run on the NIS server. ============== THE NIS CLIENT ============== STEP 1: Set the NIS domain --------------------------- Edit /etc/defaultdomain just like you did on the server and enter the name of your NIS domain. STEP 2: Edit /etc/yp.conf -------------------------- Open /etc/yp.conf in a text editor and make sure this line is present: ypserver Specify either the IP address or hostname of your NIS server. If you don't have working hostnames, you must use the IP address here. STEP 3: Set the NIS domain --------------------------- Set the NIS domain by typing this command: nisdomainname `cat /etc/defaultdomain` STEP 4: Run ypbind ------------------- Start ypbind with this command: /usr/sbin/ypbind STEP 5: Test the NIS connection -------------------------------- See if the NIS server is working with this command: ypcat passwd.byname If you see the /etc/passwd entries from the NIS server, you're good to go. Otherwise, go back to the NIS server section and see if you missed any steps. STEP 6: Edit /etc/nsswitch.conf -------------------------------- You need to edit /etc/nsswitch.conf and tell it to use NIS for passwd, shadow, and group. Change those entries to: db files nis Change the automount entry to: files nis STEP 7: Enable NIS logins in /etc/passwd and /etc/group -------------------------------------------------------- Edit /etc/passwd and add this line to the end: +::::: Edit /etc/group and add this line to the end: +::: STEP 8: Create the /export directory for home directory mounting ----------------------------------------------------------------- Make sure you have that directory: mkdir -p /export STEP 9: Create an rc.autofs script ----------------------------------- The included rc.autofs script should be moved into /etc/rc.d. Edit rc.local and add this line: /etc/rc.d/rc.autofs STEP 10: Done, enable NIS stuff at bootup ------------------------------------------ Your NIS client is now configured. Edit /etc/rc.d/rc.inet2 and uncomment this block: # Setting up NIS: # (NOTE: For detailed information about setting up NIS, see the documentation # in /usr/doc/yp-tools, /usr/doc/ypbind, and /usr/doc/ypserv) # # First, we must set the NIS domainname. NOTE: this is not # necessarily the same as your DNS domainname, set in # /etc/resolv.conf! The NIS domainname is the name of a domain # served by your NIS server. if [ -r /etc/defaultdomain ]; then nisdomainname `cat /etc/defaultdomain` fi # Then, we start up ypbind. It will use broadcast to find a server. if [ -d /var/yp ] ; then echo -n " ypbind" ${NET}/ypbind fi