What you need to set up NIS?

# 5 What you need to set up NIS?

Contents of this section

## 5.1 The RPC Portmapper

To run any of the software mentioned below you will need to run the program /usr/sbin/rpc.portmap. Some Linux distributions already have the code in /etc/rc.d/rc.inet2 to start up this daemon. All you have to do is comment it out and reboot your Linux machine to activate it.

The RPC portmapper (portmap(8c)) is a server that converts TCP/IP protocol port numbers into RPC program numbers. It must be running in order to make RPC calls (which is what the NIS client software does). When an RPC server is started (like a NIS server program), it will tell portmap what port number it is listening to, and what RPC program numbers it is prepared to serve. When a client wishes to make an RPC call to a given program number, it will first contact portmap on the server machine to determine the port number where RPC packets should be sent.

Normally, standard RPC servers are started by inetd(8C), so portmap must be started before inetd is invoked.

## 5.2 Determine whether you are a Server, Slave or Client.

To answer this question you have to consider two cases:

1. Your machine is going to be part of a network with existing NIS servers
2. You do not have any NIS servers in the network yet

In the first case, you only need the client programs (ypbind, ypwhich, ypcat, yppoll, ypmatch). The most important program is ypbind. This program must be running at all times, that is, it should always appear in the list of processes. It's a so-called daemon process and needs to be started from the system's startup file (eg. /etc/rc.local). As soon as ypbind is running, your system has become a NIS client.

In the second case, if you don't have NIS servers, then you will also need a NIS server program (usually called ypserv). Section 6 describes how to set up a NIS server on your Linux machine using the 'ypserv' implementation by Peter Eriksson (`pen@lysator.liu.se`). Note that this implementation does NOT support the master-slave concept talked about in section 3. Using this software, all your NIS servers will be master servers.

## 5.3 The Software

The system library "/usr/lib/libc.a" (version 4.4.2 and better) or the shared library "/usr/lib/libc.sa" and its related DLL contain all necessary system calls to succesfully compile the NIS client and server software. Some people reported that NIS only works with "/usr/lib/libc.a" version 4.5.21 and better so if you want to play it safe don't user older libc's. The NIS client software can be obtained from:

> `

>       Site                   Directory                        File Name

>       ftp.uni-paderborn.de   /pcsoft2/linux/local/yp          yp-clients.tar.gz
>       nic.funet.fi           /pub/OS/Linux/BETA/NYS           yp-clients.tar.gz
>       sunsite.unc.edu        /pub/Linux/system/Network/admin  yp-clients.tar.gz

> `

Once you obtained the software, please follow the instructions which come with the software.

## 5.4 Setting up a NIS Client

Assuming you have succesfully compiled the software you are now ready to install the software. A suitable place for the ypbind daemon is the directory /usr/sbin.

You'll need to do this as root of course. The other binaries (ypwhich, ypcat, yppoll, ypmatch) should go in a directory accessible by all users, for example /usr/etc or /usr/local/bin. It might be a good idea to test ypbind before incorporating it in /etc/rc.d/rc.inet2.

To test ypbind do the following:

- Make sure you have your domain name set. If it is not set then issue the command:

  > `

  >                 /bin/domainname my.domain

  > `

  where `my.domain` is the domain your machine is part of.
- Start up "/usr/sbin/rpc.portmap" if it is not already running.
- Create the directory "/var/yp" if it does not exist.
- Start up "/usr/sbin/ypbind"
- Use the command "rpcinfo -p localhost" to check if ypbind was able to register its service with the portmapper. The rpcinfo should produce something like:

  > `

  >            program vers proto   port
  >             100000    2   tcp    111  portmapper
  >             100000    2   udp    111  portmapper
  >             100007    2   udp    637  ypbind
  >             100007    2   tcp    639  ypbind
  >             300019    1   udp    660

  > `

- You may also run "rpcinfo -u localhost ypbind". This command should produce something like:

  > `

  >             program 100007 version 2 ready and waiting

  > `

Finally, do not forget that for host lookups you must set (or add) "nis" to the lookup order line in your /etc/host.conf file. Please read the manpage `resolv+.8' for more details.

At this point you should be able to use NIS client programs like ypcat, etc... For example, "ypcat passwd" will give you the entire NIS password database.

IMPORTANT: If you skipped the test procedure then make sure you have set the domain name, and created the directory:

> `

>         /var/yp

> `

This directory MUST exist for ypbind to start up succesfully.

If the test worked you may now want to change the files /etc/rc.d/rc.M and /etc/rc.d/rc.inet2 on your system so that ypbind will be started up at boot time and your system will act as a NIS client. Edit the file /etc/rc.d/rc.M and look for the commands which set the domain name. Change the domain name into the name of your domain. Also, edit the file /etc/rc.d/rc.inet2, comment out the lines which start up the rpc.portmap daemon, and add the following lines just after the place where rpc.portmap is started:

> `

>         #
>         # Start the ypbind daemon
>         #
>         if [ -f ${NET}/ypbind -a -d /var/yp ]; then
>             echo -n " ypbind"
>             ${NET}/ypbind
>         fi

> `

Unlike Sun's implementation of NIS you do not need to edit /etc/passwd and /etc/group to take advantage of NIS. Sun's implementation needs a line "+:*:0:0:::" in /etc/passwd and a line "+:*:0:" in /etc/group to tell NIS to search the NIS password and group databases.

Well, that's it. Reboot the machine and watch the boot messages to see if ypbind is actually started.

IMPORTANT: Note that the netgroup feature is not yet implemented. Netgroups allow access control for every machine and every user in the NIS domain, and they require an entry like:

> `

>         +@this_machine_users

> `

in /etc/passwd. At this moment, every user in the NIS password database can access your linux machine if you run "ypbind".

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter