Transwiki:NIS Configuration on Debian
From Wikibooks, the open-content textbooks collection
Contents |
[edit] Setting Up NIS Master Server
[edit] Basic Configuration
In Debian-based Linux distributions, three files should be modified.
#/etc/defaultdomain enigma
#/etc/default/nis NISSERVER=master
# /etc/yp.conf - ypbind configuration file ypserver 127.0.0.1
In /etc/nsswitch.conf, make sure you have passwd, group, shadow and netgroup entries like this:
# /etc/nsswitch.conf passwd: compat group: compat shadow: compat netgroup: nis
[edit] Starting Server Daemon
root@enigma:/etc# init.d/portmap start * Starting portmap daemon... ...done. root@enigma:/etc# init.d/nis start Starting NIS services: ypserv yppasswdd ypxfrd ypbind
On success, the following information is expected:
root@enigma:/etc# rpcinfo -p localhost
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100007 2 udp 717 ypbind
100007 1 udp 717 ypbind
100007 2 tcp 720 ypbind
100007 1 tcp 720 ypbind
100009 1 udp 706 yppasswdd
600100069 1 udp 709 fypxfrd
600100069 1 tcp 711 fypxfrd
100004 2 udp 704 ypserv
100004 1 udp 704 ypserv
100004 2 tcp 708 ypserv
100004 1 tcp 708 ypserv
Sometimes you might not see ypbind and fypxfrd in the list. You should finish the next step and rerun the command.
[edit] Initializing Master Server
root@enigma:/etc# /usr/lib/yp/ypinit -m
At this point, we have to construct a list of the hosts which will run NIS
servers. localhost.localdomain is in the list of NIS server hosts. Please continue to add
the names for the other hosts, one per line. When you are done with the
list, type a <control D>.
next host to add: localhost.localdomain
next host to add:
The current list of NIS servers looks like this:
localhost.localdomain
Is this correct? [y/n: y] y
We need a few minutes to build the databases...
Building /var/yp/enigma/ypservers...
Running /var/yp/Makefile...
make[1]: Entering directory `/var/yp/enigma'
Updating passwd.byname...
Updating passwd.byuid...
......
Updating shadow.byname...
make[1]: Leaving directory `/var/yp/enigma'
localhost.localdomain has been set up as a NIS master server.
Now you can run ypinit -s localhost.localdomain on all slave server.
Be sure to start portmap before typing this command, otherwise you will get an error and have to manually delete /var/yp/enigma.
[edit] Adding New Users
It is recommanded to add groups and users by using addgroup and adduser scripts, which are able to synchronize NIS information automatically. If not, you should do this manually after adding new groups or users:
root@enigma:/etc# cd /var/yp root@enigma:/var/yp# make make[1]: Entering directory `/var/yp/enigma' Updating passwd.byname... Updating passwd.byuid... Updating netid.byname... Updating shadow.byname... make[1]: Leaving directory `/var/yp/enigma'
NIS clients should restart /etc/init.d/nis service in order to keep updated.
[edit] Setting Up NIS Client
[edit] Basic Configuration
Like server configuration, make sure you have passwd, group, shadow and netgroup entries like this:
# /etc/nsswitch.conf passwd: compat group: compat shadow: compat netgroup: nis
Then configure NIS domain name and NIS server:
# /etc/defaultdomain enigma
# /etc/yp.conf ypserver enigma
Your /etc/hosts should contain a line like:
# /etc/hosts 192.168.4.131 enigma
[edit] Modifying Authentication Files
root@nis-client:/etc# echo '+::::::' >> /etc/passwd root@nis-client:/etc# echo '+::::::::' >> /etc/shadow root@nis-client:/etc# echo '+:::' >> /etc/group
It is also possible to grant or restrict the access of specified users. It is a little complex and will not be discussed here. Refer to Debian NIS HOWTO if you want to know more.
[edit] Starting Client Daemon
root@nis-client:/etc# /etc/init.d/portmap start * Starting portmap daemon... ...done. root@nis-client:/etc# /etc/init.d/nis start Starting NIS services: ypbind