This is the way I configured NIS on my local network:
First of all, you can choose to use the /etc/yp.conf to configure the address of your NIS server, or you can use the default broadcast method.
Using broadcast won't work if you have a router, nat or firewall separating different computers.
Second, you need to choose a name for your NIS-domain. This does not have to be (and actually
should not be for security reasons) your DNS domain.
A - On your server:
1) Edit /etc/yp.conf with this line:
Code:
domain <NAME_OF_YOUR_NISDOMAIN> server 127.0.0.1
2) Edit in /etc/nsswitch.conf the lines that define the order for looking up users and groups:
Code:
passwd: files nis
shadow: files nis
group: files nis
3) Edit /var/yp/securenets to define your local network, for example:
Code:
255.255.255.0 192.168.1.0
4) Set your nis-domainname:
Code:
# domainname <NAME_OF_YOUR_NISDOMAIN>
# domainname > /etc/defaultdomain
5) Edit in /var/yp/Makefile the following lines:
Code:
MERGE_PASSWD=false
MERGE_GROUP=false
6) Now you have to uncomment some lines in /etc/rc.d/rc.yp so that it actually does something:
Code:
... (set nisdomain:)
if [ -r /etc/defaultdomain ]; then
nisdomainname `cat /etc/defaultdomain`
fi
... (start server:)
if [ -x /usr/sbin/ypserv ]; then
echo "Starting NIS server: /usr/sbin/ypserv"
/usr/sbin/ypserv
fi
... (start password server:)
if [ -x /usr/sbin/rpc.yppasswdd ]; then
echo "Starting NIS master password server: /usr/sbin/rpc.yppasswdd"
/usr/sbin/rpc.yppasswdd
# echo "Starting NIS master password server: /usr/sbin/rpc.yppasswdd -e chsh -e chfn"
# /usr/sbin/rpc.yppasswdd -e chsh -e chfn
fi
... (start client, even on this server:)
if [ -d /var/yp ]; then
echo "Starting NIS services: /usr/sbin/ypbind -broadcast"
/usr/sbin/ypbind -broadcast
fi
7) Make /etc/rc.d/rc.yp executable if it is not already:
Code:
# chmod +x /etc/rc.d/rc.yp
8) Make /etc/rc.c/rc.rpc executable so that yp can use portmapping:
Code:
# chmod +x /etc/rc.d/rc.rpc
9) Start rpc & yp:
Code:
# /etc/rc.d/rc.rpc start
# /etc/rc.d/rc.yp
10) Build the NIS databases:
11) Check if ypbind is listening to clients:
Code:
# rpcinfo -u localhost ypbind
(Should show something like "100007 ready and waiting")
12) Everytime you add a new user or group, rebuild the yp databases with "make -c /var/yp". You can add this line to the end of the useradd script etc.
B - On your clients:
1) If you cannot use broadcast, edit /etc/yp.conf with this line:
Code:
domain <NAME_OF_YOUR_NISDOMAIN> server <IP_ADDRESS_OF_YOUR_NISSERVER>
2) Edit in /etc/nsswitch.conf the lines that define the order for looking up users and groups and hosts:
Code:
passwd: files nis
shadow: files nis
group: files nis
...
hosts: files nis
3) Set your nis-domainname:
Code:
# domainname <NAME_OF_YOUR_NISDOMAIN>
# domainname > /etc/defaultdomain
4) Now you have to uncomment some lines in /etc/rc.d/rc.yp so that it actually does something:
Code:
... (set nisdomain:)
if [ -r /etc/defaultdomain ]; then
nisdomainname `cat /etc/defaultdomain`
fi
... (start client:)
if [ -d /var/yp ]; then
echo "Starting NIS services: /usr/sbin/ypbind -broadcast"
/usr/sbin/ypbind -broadcast
fi
*NOTE*: Remove -broadcast (2x) if you're behind a router, NAT, etc.
5) Make /etc/rc.d/rc.yp executable if it is not already:
Code:
# chmod +x /etc/rc.d/rc.yp
6) Make /etc/rc.c/rc.rpc executable so that yp can use portmapping:
Code:
# chmod +x /etc/rc.d/rc.rpc
7) Start rpc & yp:
Code:
# /etc/rc.d/rc.rpc start
# /etc/rc.d/rc.yp
8) Modify your passwd / group and the two shadow files:
Code:
# echo +:::::: >> /etc/passwd (6x :)
# echo +::: >> /etc/group (3x :)
# echo +:::::::: >> /etc/shadow (8x :)
# echo +::: >> /etc/gshadow (3x :)
(Not including these ":" can give you some problems with kde sessions I noticed the hard way...)
9) Check if ypbind is listening to clients:
Code:
# rpcinfo -u localhost ypbind
(Should show something like "100007 ready and waiting")
10) Test if your NIS client is communicating with your NIS server:
This should show you all common users on your NIS server. (That's one reason why NIS is insecure...)
C - More information:
Check out
http://tldp.org/HOWTO/NIS-HOWTO/index.html
Happy Slacking!