How To Set Up NIS for Ubuntu servers
Last updated on May 9, 2022 8:28 PM
Network Information Service (NIS) is a distributed naming service based on Remote Procedure Call (RPC). It enables easy sharing of various information across the cluster including username, password, hosts and service ports. Such a centralized user management system is also a necessary prerequisite for setting up cluster management system including SLURM, which requires user & group synchronization across the cluster.
NIS architecture overview
NIS uses a client-server arrangement. By running NIS, the system administrator can distribute administrative databases, called maps, among a variety of servers. Servers are further divided into master and slave servers: the master server is the true single owner of the map data. Slave NIS servers handle client requests, but they do not modify the NIS maps. The master server is responsible for all map maintenance and distribution to its slave servers. Once an NIS map is built on the master to include a change, the new map file is distributed to all slave servers.
Clients are hosts that request information from these maps. NIS clients “see” these changes when they perform queries on the map file — it doesn’t matter whether the clients are talking to a master or a slave server, because once the map data is distributed, all NIS servers have the same information.
NIS uses domains to arrange the machines, users, and networks in its namespace. However, it does not use a domain hierarchy; an NIS namespace is flat.
Set Up NIS
NIS Master
1.Install NIS
1 |
|
You’ll be prompted to enter your preferred domain name during the installation process. Here the domain name is hulk.nis
.
1 |
|
2. Edit /etc/default/nis
1 |
|
Specifically, edit NISSERVER
to be master
1 |
|
3. Edit /etc/hosts
In master’s /etc/hosts
, there should be at least all the slave servers.
1 |
|
1 |
|
TIPS: NIS usually is for info sharing in LAN. However, as long as port 111
(for rpcbind
) is open, it is capable of doing RPC call across internet.
4. Edit /etc/ypserv/securenets
1 |
|
1 |
|
5. Run ypinit -m
By running ypinit -m
, NIS will utilize the local user system as its cornerstone to build the network user information.
1 |
|
You’ll be prompted to enter the list of servers (master and slave). The first host added should be the hostname of the master server, followed by all the slave servers in the system.
1 |
|
NIS client
1. Install NIS
1 |
|
During the process it will also prompt to enter domain name. Use the same domain as the NIS master.
2. Edit /etc/yp.conf
1 |
|
Add the master / slave server you want to request info from.
1 |
|
If you want to use hostname instead of server IP, make sure to specify it in /etc/hosts
of the client.
3. Edit /etc/nsswitch.conf
The name service switch (named nsswitch.conf
) controls how a client machine or application obtains network information.
Each machine has a switch file in its /etc
directory. Each line of that file identifies a particular type of network information, such as host
, password
, and group
, followed by one or more locations of that information.
A client can obtain naming information from one or more of the switch’s sources. For example, an NIS client could obtain its hosts information from an NIS map and its password information from a local /etc
file. In addition, the client could specify the conditions under which the switch must use each source.
The available information sources are listed in the following table:
Information Sources | Description |
---|---|
files | A file stored in the client’s /etc directory. For example, /etc/passwd |
nisplus | An NIS+ table. For example, the hosts table. |
nis | An NIS map. For example, the hosts map. |
compat | compat can be used for password and group information to support old-style + or - syntax in /etc/passwd , /etc/shadow , and /etc/group files. |
dns | Can be used to specify that host information be obtained from DNS. |
ldap | Can be used to specify entries be obtained from the LDAP directory. |
Open /etc/nsswitch.conf
to add nis
as an information source.
1 |
|
Add nis
to the end of passwd
, group
, shadow
, gshadow
and hosts
.
1 |
|
If you want to look up nis
first instead of local files. Put nis [NOTFOUND=return]
in front of files
. The [NOTFOUND=return]
search criterion instructs the switch to stop searching the NIS tables if the switch gets a “No such entry” message. The switch searches through local files only if the NIS server is unavailable.
1 |
|
On Debian
also:
1 |
|
4. Edit /etc/pam.d/common-session
for creating home directory automatically
1 |
|
1 |
|
5. Restart NIS to apply changes
1 |
|
NIS Slave
The set up process of slave server is an approximate combination of client set up + master set up.
1. Go through NIS client set-up steps
Specifically Step 1 to 4. This is for establishing RPC connection with master.
2. Edit /etc/default/nis
1 |
|
Specifically, edit NISSERVER
to be slave
1 |
|
3. Edit /etc/ypserv.securenets
1 |
|
It is important to allow the master server to access.
1 |
|
4. Edit /etc/hosts
1 |
|
In slave’s /etc/hosts
, there should be at least the IP of master server.
1 |
|
5. Run ypinit -s <master>
1 |
|
This operation will pull information from the master to the slave.
Additional steps: master server set up
If the slave master is not added in Step 5 of master set up. On master server, it is necessary to rerun ypinit -m
and add the slave server when it prompts to enter the hosts.
In order to push the changes in the maps on master, you also need to edit the /var/yp/Makefile
:
1 |
|
Modify NOPUSH=fasle
to NOPUSH=true
.
1 |
|
Bibliography
- System Administration Guide: Naming and Directory Services (DNS, NIS, and LDAP)
- Eisler, M., Labiaga, R., & Stern, H. (2001). Managing NFS and NIS: Help for Unix System Administrators. O’Reilly Media, Inc.
- How to set up NIS for Ubuntu (Master, Client, Slave) — Junyong Lee
- 鳥哥的 Linux 私房菜:伺服器架設篇 — 第十四章、帳號控管: NIS 伺服器