Network Information System
Network Information System
What Is It?
NIS, which stands for Network Information Services, was developed by Sun Microsystems to
centralize administration of UNIX® (originally SunOS™) systems.
It is a RPC-based client/server system that allows a group of machines within an NIS domain to
share a common set of configuration files. This permits a system administrator to set up NIS
client systems with only minimal configuration data and add, remove or modify configuration
data from a single location.
Term Description
An NIS master server and all of its clients (including its slave servers)
NIS have a NIS domainname. Similar to an Windows NT domain name,
domainname the NIS domainname does not have anything to do with DNS.
“Binds” an NIS client to its NIS server. It will take the NIS
domainname from the system, and using RPC, connect to the server.
ypbind is the core of client-server communication in an NIS
ypbind
environment; if ypbind dies on a client machine, it will not be able to
access the NIS server.
Should only be running on NIS servers; this is the NIS server process
itself. If ypserv(8) dies, then the server will no longer be able to
respond to NIS requests (hopefully, there is a slave server to take over
for it). There are some implementations of NIS (but not the FreeBSD
ypserv one), that do not try to reconnect to another server if the server it used
before dies. Often, the only thing that helps in this case is to restart the
server process (or even the whole server) or the ypbind process on the
client.
Term Description
Setting up a master NIS server can be relatively straight forward, depending on your needs.
FreeBSD comes with support for NIS out-of-the-box. All you need is to add the following lines
to /etc/rc.conf, and FreeBSD will do the rest for you.
1. nisdomainname="test-domain"
This line will set the NIS domainname to test-domain upon network setup (e.g. after
reboot).
2. nis_server_enable="YES"
This will tell FreeBSD to start up the NIS server processes when the networking is next
brought up.
3. nis_yppasswdd_enable="YES"
This will enable the rpc.yppasswdd daemon which, as mentioned above, will allow
users to change their NIS password from a client machine.
After setting up the above entries, run the command /etc/netstart as superuser. It will set up
everything for you, using the values you defined in /etc/rc.conf. As a last step, before
initializing the NIS maps, start the ypserv daemon manually:
# /etc/rc.d/ypserv start
The NIS maps are database files, that are kept in the /var/yp directory. They are generated from
configuration files in the /etc directory of the NIS master, with one exception: the
/etc/master.passwd file. This is for a good reason, you do not want to propagate passwords to
your root and other administrative accounts to all the servers in the NIS domain. Therefore,
before we initialize the NIS maps, you should:
# cp /etc/master.passwd /var/yp/master.passwd
# cd /var/yp
# vi master.passwd
When you have finished, it is time to initialize the NIS maps! FreeBSD includes a script named
ypinit to do this for youBecause we are generating maps for an NIS master, we are going to
pass the -m option to ypinit. To generate the NIS maps, assuming you already performed the
steps above, run:
Please continue to add any slave servers, one per line. When you are
ellington
coltrane
ellington# vi /var/yp/Makefile
NOPUSH = "True"
Setting up an NIS slave server is even more simple than setting up the master. Log on to the
slave server and edit the file /etc/rc.conf as you did before. The only difference is that we
now must use the -s option when running ypinit. The -s option requires the name of the NIS
master be passed to it as well, so our command line looks like:
Transferring netgroup...
Transferring netgroup.byuser...
Transferring netgroup.byhost...
Transferring passwd.byuid...
Transferring passwd.byname...
Transferring group.bygid...
Transferring group.byname...
Transferring services.byname...
Transferring rpc.bynumber...
Transferring rpc.byname...
Transferring protocols.byname...
Transferring master.passwd.byname...
Transferring networks.byname...
Transferring networks.byaddr...
Transferring netid.byname...
Transferring hosts.byaddr...
Transferring protocols.bynumber...
Transferring ypservers...
You should now have a directory called /var/yp/test-domain. Copies of the NIS master
server's maps should be in this directory. You will need to make sure that these stay updated. The
following /etc/crontab entries on your slave servers should do the job:
20 * * * * root /usr/libexec/ypxfr
passwd.byname
These two lines force the slave to sync its maps with the maps on the master server. Although
these entries are not mandatory, since the master server attempts to ensure any changes to its NIS
maps are communicated to its slaves and because password information is vital to systems
depending on the server, it is a good idea to force the updates. This is more important on busy
networks where map updates might not always complete.
Now, run the command /etc/netstart on the slave server as well, which again starts the NIS
server.
NIS Clients
An NIS client establishes what is called a binding to a particular NIS server using the ypbind
daemon. ypbind checks the system's default domain (as set by the domainname command), and
begins broadcasting RPC requests on the local network. These requests specify the name of the
domain for which ypbind is attempting to establish a binding. If a server that has been
configured to serve the requested domain receives one of the broadcasts, it will respond to
ypbind, which will record the server's address. If there are several servers available (a master
and several slaves, for example), ypbind will use the address of the first one to respond. From
that point on, the client system will direct all of its NIS requests to that server. ypbind will
occasionally “ping” the server to make sure it is still up and running. If it fails to receive a reply
to one of its pings within a reasonable amount of time, ypbind will mark the domain as unbound
and begin broadcasting again in the hopes of locating another server.
1. Edit the file /etc/rc.conf and add the following lines in order to set the NIS
domainname and start ypbind upon network startup:
nisdomainname="test-domain"
nis_client_enable="YES"
2. To import all possible password entries from the NIS server, remove all user
accounts from your /etc/master.passwd file and use vipw to add the following
line to the end of the file:
+:::::::::
3.To import all possible group entries from the NIS server, add this line to your
/etc/group file:
+:*::
To start the NIS client immediately, execute the following commands as the superuser:
# /etc/netstart
# /etc/rc.d/ypbind start
After completing these steps, you should be able to run ypcat passwd and see the NIS
server's passwd map.
127.0.0.1 255.255.255.255
192.168.128.0 255.255.255.0
# allow connections from any host
10.0.0.0 255.255.240.0
If ypserv(8) receives a request from an address that matches one of these rules, it will process the
request normally. If the address fails to match a rule, the request will be ignored and a warning
message will be logged. If the /var/yp/securenets file does not exist, ypserv will allow
connections from any host.
The ypserv program also has support for Wietse Venema's TCP Wrapper package. This allows
the administrator to use the TCP Wrapper configuration files for access control instead of
/var/yp/securenets.
Note: While both of these access control mechanisms provide some security, they, like the
privileged port test, are vulnerable to “IP spoofing” attacks. All NIS-related traffic should be
blocked at your firewall.
Servers using /var/yp/securenets may fail to serve legitimate NIS clients with archaic TCP/IP
implementations. Some of these implementations set all host bits to zero when doing broadcasts
and/or fail to observe the subnet mask when calculating the broadcast address. While some of
these problems can be fixed by changing the client configuration, other problems may force the
retirement of the client systems in question or the abandonment of /var/yp/securenets.
The use of the TCP Wrapper package increases the latency of your NIS server. The additional
delay may be long enough to cause timeouts in client programs, especially in busy networks or
with slow NIS servers. If one or more of your client systems suffers from these symptoms, you
should convert the client systems in question into NIS slave servers and force them to bind to
themselves.
There is a way to bar specific users from logging on to a machine, even if they are present in the
NIS database. To do this, all you must do is add -username to the end of the
/etc/master.passwd file on the client machine, where username is the username of the user
you wish to bar from logging in. This should preferably be done using vipw, since vipw will
sanity check your changes to /etc/master.passwd, as well as automatically rebuild the
password database when you finish editing. For example, if we wanted to bar user bill from
logging on to basie we would:
basie# vipw
vipw: done
root:[password]:0:0::0:0:The super-user:/root:/bin/csh
operator:*:2:5::0:0:System &:/:/sbin/nologin
tty:*:4:65533::0:0:Tty Sandbox:/:/sbin/nologin
kmem:*:5:65533::0:0:KMem Sandbox:/:/sbin/nologin
games:*:7:13::0:0:Games pseudo-user:/usr/games:/sbin/nologin
news:*:8:8::0:0:News Subsystem:/:/sbin/nologin
bind:*:53:53::0:0:Bind Sandbox:/:/sbin/nologin
uucp:*:66:66::0:0:UUCP pseudo-
user:/var/spool/uucppublic:/usr/libexec/uucp/uucico
xten:*:67:67::0:0:X-10 daemon:/usr/local/xten:/sbin/nologin
nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/sbin/nologin
+:::::::::
-bill
basie#
# pw useradd jsmith
# cd /var/yp
# make test-domain
Keep the administration accounts out of the NIS maps. You do not want to be
propagating administrative accounts and passwords to machines that will have
users that should not have access to those accounts.
Keep the NIS master and slave secure, and minimize their downtime. If somebody
either hacks or simply turns off these machines, they have effectively rendered
many people without the ability to login to the lab.
This is the chief weakness of any centralized administration system. If you do not
protect your NIS servers, you will have a lot of angry users!