NIS service configuration instance on RHEL

Source: Internet
Author: User
The NIS service configuration instance on RHEL-Linux Enterprise Application-Linux server application information. For more information, see. NIS Overview:

NIS, short for Network Information Services, was originally developed by Sun Microsystems for centralized management of UNIX systems. At present, it has basically become the industry standard; all mainstream UNIX-like systems (Solaris, HP-UX, AIX, Linux, NetBSD, OpenBSD, FreeBSD and so on) Support NIS.
NIS was originally named Yellow Pages, but Sun renamed it the current name due to trademark issues. NIS is an RPC-based client/server system that allows a group of machines in an NIS domain to share a series of configuration files. In this way, the system administrator can configure the NIS client system that only contains the most basic configuration data, and add, delete, or modify configuration data on a single point (primary NIS Server.
In the NIS environment, there are three types of hosts: master, slave, and client ). The server acts as a central database for host configuration information, stores authoritative copies of user accounts, group accounts, and other configuration information, while the slave server stores redundant copies of this information. The client uses this information.

Configuration example:

In this example, the network model is as follows:
Server 192.168.0.16 NIS master server
Client 192.168.0.128 NIS client

1. Server Settings

1. Set the NIS domain name

# Nisdomainname benet

# Vi/etc/sysconfig/network
Add:
NISDOMAIN = benet

# Vi/etc/rc. local
Add:
/Sbin/nisdomainname benet

2. By default, The ypserv package is not installed in RHEL4. This software is installed on the first disc.

Check whether ypserv has been installed
# Rpm-qa | grep ^ yp
Ypbind-1.17.2-3
Yp-tools-2.8-7

Mount the first disc and install ypserv
# Mount/dev/cdrom/media/cdrom
# Rpm-ivh/media/cdrom/RedHat/RPMS/ypserv-2.13-5.i386.rpm
Warning:/media/cdrom/RedHat/RPMS/ypserv-2.13-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ######################################## ### [100%]
1: ypserv ####################################### #### [100%]

3. Main configuration file/etc/ypserv. conf

This part of configuration is relatively simple, and most of the configurations can be kept by default. The last section defines the access security. However, in general, the administrator should use the securenets file, not necessarily using ypserv. conf to define security.

The syntax is as follows:
[Host]: [Domain]: [Map]: [Security]
[Host Name/IP address]: [NIS domain name]: [available database name]: [security restrictions]

The fields are as follows:
Host: The computer authorized or inaccessible. It is determined by the address/mask pair. For example, 192.168.1.0/255.255.255.0. * indicates all hosts;
Map: the name of the accessed NIS ing table. Example: passwd. byuid. * Indicates that all fields in the ing table are available;
Security: Authorized access type
None: access is allowed. Security is not enhanced;
Port: Allows access from a privileged port. Only connections with the source port less than 1024 are received;
Deny: Access prohibited;

In this experiment, we should set the following items at the end of the main configuration file:
127.0.0.0/255.255.255.0: *: none
192.168.0.0/255.255.255.0: *: none
*: Deny

4. Edit the/etc/yp. conf file.

The NIS server is also their own NIS client, so you need to edit the NIS client configuration file/etc/yp. conf and record the domain's NIS server as a host.
# Vi/etc/yp. conf
Add:
Ypserver 127.0.0.1

5. Start rpc, ypserv, yppasswdd, and other processes.

# Service portmap start
Starting portmap: [OK]
# Rpcinfo-p localhost
Program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 32768 status
100024 1 tcp 32768 status

# Service ypserv start
Starting YP server services: [OK]
# Rpcinfo-u localhost ypserv
Program 100004 version 1 ready and waiting
Program 100004 version 2 ready and waiting
#
Service yppasswdd start
Starting YP passwd service: [OK]
# Rpcinfo-u localhost yppasswdd
Program 100009 version 1 ready and waiting

# Rpcinfo-p localhost
Program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 32768 status
100024 1 tcp 32768 status
100004 2 udp 613 ypserv
100004 1 udp 613 ypserv
100004 2 tcp 616 ypserv
100004 1 tcp 616 ypserv
100009 1 udp 628 yppasswdd

6. initialize the NIS domain

Next, run the ypinit command to create the domain maps file.

#/Usr/lib/yp/ypinit-m
At this point, we have to construct a list of the hosts which will run NIS
Servers. server.mshome.net 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
List, type .
Next host to add: server.mshome.net
Next host to add:
The current list of NIS servers looks like this:
Server

Is this correct? [Y/n: y] y
We need a few minutes to build the databases...
Building/var/yp/benet/ypservers...
Running/var/yp/Makefile...
Gmake [1]: Entering directory '/var/yp/benet'
Updating passwd. byname...
Updating passwd. byuid...
Updating group. byname...
Updating group. bygid...
Updating hosts. byname...
Updating hosts. byaddr...
Updating rpc. byname...
Updating rpc. bynumber...
Updating services. byname...
Updating services. byservicename...
Updating netid. byname...
Updating protocols. bynumber...
Updating protocols. byname...
Updating mail. aliases...
Gmake [1]: Leaving directory '/var/yp/benet'
Server has been set up as a NIS master server.
Now you can run ypinit-s server on all slave server.

7. Set/var/yp/securenets, configure Secure Access, and add the following content (you can modify it based on your network ):
Host 127.0.0.1
255.255.255.0 192.168.0.0

Note: This file is used to define the client's access permissions to the NIS server. It is defined by netmask/network. In actual use, the '/' symbol must be replaced with a space. At the same time, if you only want to define access to a host, you need to replace the mask with the 'host' command.

8. Start the client process and test the NIS server.

# Service ypbind start
Binding to the NIS domain: [OK]
Listening for an NIS domain server ..
[Root @ server ~] # Yptest
Test 1: domainname
Configured domainname is "benet"
Test 2: ypbind
Used NIS server: 192.168.0.16
..................
..................

# Ypwhich-x
Use "ethers" for map "ethers. byname"
Use "aliases" for map "mail. aliases"
Use "services" for map "services. byname"
Use "protocols" for map "protocols. bynumber"
Use "hosts" for map "hosts. byname"
Use "networks" for map "networks. byaddr"
Use "group" for map "group. byname"
Use "passwd" for map "passwd. byname"

# Ypcat passwd
Redhat: $1 $ btyeQR8Z $ TR0OkRrcrXYmgxY. MEN2R.: 500: 501:/home/redhat:/bin/bash
Note: redhat is a manually created system account.

# Ypmatch redhat passwd
Redhat: $1 $ btyeQR8Z $ TR0OkRrcrXYmgxY. MEN2R.: 500: 501:/home/redhat:/bin/bash

Ii. Client settings

1. Set the NIS domain name
# Nisdomainname benet
# Vi/etc/sysconfig/network
Add:
NISDOMAIN = benet
# Vi/etc/rc. local
Add:
/Sbin/nisdomainname benet

2. Check whether the corresponding rpm packages ypbind and yptools are installed. RHEL4 is installed by default.
# Rpm-qa | grep ^ yp
Ypbind-1.17.2-3
Yp-tools-2.8-7

3. Set the main configuration file/etc/yp. conf.
# Vi/etc/yp. conf
Add the following lines:
Domain benet server 192.168.0.16
The syntax format is:
Domain NISDOMAIN server HOSTNAME
Among them, NISDOMAIN is your NIS domain name, HOSTNAME is your NIS Server name, and IP is recommended. Alternatively, you can set the/etc/hosts file and use the client to parse the Host Name of the NIS Server, the Host Name of the server can be written here;

4. Set the/etc/nsswitch. conf file

Find the following items:
Passwd: files
Shadow: files
Group: files
# Hosts: db files ldap nis dns
Hosts: files dns

Modify it:
Passwd: files nis
Shadow: files nis
Group: files nis
# Hosts: db files ldap nis dns
Hosts: files nis dns

5. Check the startup status of the portmap Process on the client, and start the ypbind process after confirmation:

# Service portmap status
Portmap (pid 1774) is running...

# Service ypbind start
Shutting down NIS services: [OK]
Binding to the NIS domain: [OK]
Listening for an NIS domain server.

Set ypbind to start automatically
# Chkconfig -- level 2345 ypbind on

6. Test Client Connection

# Ypcat passwd
Redhat: $1 $ btyeQR8Z $ TR0OkRrcrXYmgxY. MEN2R.: 500: 501:/home/redhat:/bin/bash

# Ypmatch redhat passwd
Redhat: $1 $ btyeQR8Z $ TR0OkRrcrXYmgxY. MEN2R.: 500: 501:/home/redhat:/bin/bash

# Ypwhich-x
Use "ethers" for map "ethers. byname"
Use "aliases" for map "mail. aliases"
Use "services" for map "services. byname"
Use "protocols" for map "protocols. bynumber"
Use "hosts" for map "hosts. byname"
Use "networks" for map "networks. byaddr"
Use "group" for map "group. byname"
Use "passwd" for map "passwd. byname"

# Ypcat hosts
192.168.0.16 server
127.0.0.1 localhost. localdomain localhost

7. Configure the client to log on to the NIS domain at startup

# Vi/etc/sysconfig/authconfig
Find the following line:
USENIS = no
To:
USENIS = yes

8. Add test users to the server
# Userdd nisuser
# Passwd nisuer
Run the following command to recreate the maps database. For details about how to use the database, see settings on the server.
#/Usr/lib/yp/ypinit-m

3. Restart the client to test the result.

1. Client Logon:
# Ssh-l nisuser 192.168.0.128
Nisuser@192.168.0.128's password:
Last login: Wed Jul 11 17:59:14 2007 from server
Cocould not chdir to home directory/home/nisuser: No such file or directory
-Bash-3.00 $

2. Output The/home directory on the server to make the client roaming the configuration file:

# Vi/etc/exports
/Home 192.168.0.0/24 (rw, no_root_squash, async)

Start the nfs service:
# Service nfs start
Starting NFS services: [OK]
Starting NFS quotas: [OK]
Starting NFS daemon: [OK]
Starting NFS mountd: [OK]

Set Automatic startup
# Chkconfig -- level 2345 nfs on

3. Client settings

Log on to the client as a root user, mount the/home directory of the server to the/home directory of the local machine, and then test the log on using the nisuser
# Ssh-l nisuser 192.168.0.128
Nisuser@192.168.0.128's password:
[Nisuser @ client ~] $ Ls-
... Bash_logout. bash_profile. bashrc. emacs. gtkrc. kde
[Nisuser @ client ~] $ Ls/home
Lost + found nisuser redhat

Edit the/etc/fstab file so that it can be automatically mounted upon startup.
192.168.0.16:/home ext3 defaults 0 0

4. Use the yppasswd command on the client to change the password.

[Nisuser @ client ~] $ Yppasswd
Changing NIS account information for nisuser on server.
Please enter old password: <---- enter the old password here
Changing NIS password for nisuser on server.
Please enter new password: <---- new password
Please retype new password: <---- confirm the new password
The NIS password has been changed on server. <---- confirm The modification.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.