How to Install and Configure Network Information Service (NIS Server) on Ubuntu, Debian and Linux Mint - Cloud Network

Networking | Support | Tricks | Troubleshoot | Tips

Buymecoffe

Buy Me A Coffee

Tuesday, October 22, 2019

How to Install and Configure Network Information Service (NIS Server) on Ubuntu, Debian and Linux Mint

 




What is NiS ?
NIS is a Remote Procedure Call (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 to add, remove, or modify configuration data from a single location.

Note :- 
1.  This assumes your Server and Clients have Static IP Addresses.
2.  NIS with Dynamic IP Addresses present a serious security hazard

For Test Purpose Only
Server  :- 192.168.1.101
Client   :-  192.168.1.102

Domain Name :- ubuntu.com or ubuntu.local
Use Same Domain Name in Client System

Now on Server Side
Step1 :- su
Step2 :- ifconfig
Step3 :- sudo apt-get install portmap nis (ubuntu.local)

Note :- Remember this parameter is case sensitive. It is probably a good idea to then add a portmap line to hosts for security reasons.
Step4 :- sudo nano /etc/hosts.allow
portmap : <NIS server IP address>


Hosts file Edit
Step3 :- sudo nano /etc/hosts
192.168.1.101 server.ubuntu.local   ubuntuserver
192.168.1.102 server.ubuntu.local   ubuntuclient

Update Portmap
Step5 :- sudo update-rc.d portmap defaults 10

Step6 :- sudo nano /etc/defaults/nis (Change)
               NISSERVER = master
               NISCLIENT = false

Step7 :- sudo nano /etc/yp.conf 
        domain <domainname> server <servername>

Step8 :- sudo nano /var/yp/makefile --  (Change)

All = passwd shadow group hosts rpc services netid protocols
The only thing I changed was the MINGID line to 1

Step9   :- sudo nano /etc/ypserv.serv -- ip address
255.255.255.0    192.168.1.0 (giving access to everybody)

Step10 :- sudo /etc/init.d/portmap restart
Step11 :- sudo /etc/init.d/nis restart
Step12 :- sudo /etc/init.d/ypserv restart

Step13 :- sudo /usr/lib/yp/ypinit -m  -- server

Step14 :- sudo useradd -d /home/User1 -m User1
Step15 :- sudo useradd -d /home/User2 -m User2
Step16 :- sudo passwd User1
Step17 :- sudo passwd User2
Step18 :- cd /var/yp
Step19 :- make

Testing
Step20 :- ypcat passwd
Step21 :- sudo ubuntu.local
Step22 :- ping ubuntu.local or domain name

Now on Clients Side
Step23 :- su
Step24 :- ifconfig
Step25 :- sudo nano /etc/hosts
192.168.1.102   server.ubuntu.local  ubuntuclient
192.168.1.101   ubuntu.ubuntu.local ubuntuserver


Step26 :- ping my domainname

Install portmap & nis (ubuntu.local)
Step27 :- sudo apt-get install portmap nis

Update portmap defaults
Step28 :- sudo update-rc.d portmap defaults 10

Step29 :- sudo  nano /etc/hosts.allow
portmap : <NIS server IP address>

Step25 :- sudo nano /etc/pam.d/common-session
session optional       pam_mkhomedir.so skel=/etc/skel umask=077

Edit /etc/yp.conf and add a server line
Step26 :- sudo nano /etc/yp.conf
  Ex :- domain    ubuntu.local   server   server.ubuntu.local

Edit /etc/nsswitch.conf
Step27:- sudo nano /etc/nsswitch.conf(need to add only nis)
Ex :- passwd   :     nis compat
         group     :      nis compat
         shadow  :     nis compat
         hosts      :    file dns nis
OR
Setup name services to use NIS:
sudo nano /etc/passwd (to add a line at the end saying)
+::::::
sudo nano /etc/group (to add a line at the end saying)
+:::
sudo nano /etc/shadow (to add a line at the end saying)
+::::::::

Reboot NIS Client
Step29 :- sudo reboot

Test it
Step30 :- ypcat passwd and ypcat hosts

Step31 :- ypwhich (it will show domain name)
Ex :-  server.ubuntu.local

Exit.


Login with NIS user (such as NISUser1 or NISUser2)
Step32 :-  su - NISUser1
Step33 :-   pwd and Exit it.

Logout and Login With (NISUser1 or NISUser2)

NIS Terms and Processes

Server Side
su
ifconfig
sudo apt-get install portmap nis  or
sudo apt-get install portmap
sudo update-rc.d portmap defaults 10
sudo apt-get install nis     --    ubuntuserver.com
Note :- Remember this parameter is case sensitive. It is probably a good idea to then add a portmap line to hosts for security reasons
sudo nano /etc/hosts.allow
portmap : <NIS server IP address>
sudo nano /etc/defaults/nis -- master
Edit sudo nano /etc/default/nis (Change)
Step6 :-  NISSERVER = master
Step7 :- NISCLIENT = false
sudo nano /etc/yp.conf  -- domain <domainname> server <servername>
sudo nano /var/yp/makefile --  shadow
The only thing I changed was the MINGID line to 1
sudo nano /etc/ypserv.serv -- ipadress
sudo /etc/init.d/portmap restart
sudo /etc/init.d/nis restart
sudo /etc/init.d/ypserv restart
sudo /usr/lib/yp/ypinit -m  -- server
sudo useradd -d /home/User1 -m User1
sudo useradd -d /home/User2 -m User2
sudo passwd User1
sudo passwd User2
cd /var/yp
make
ypcat passwd

Client Side
su
ifconfig
ping ubuntu and ping servername.ubuntuserver.com
sudo apt-get install portmap nis -- ubuntuserver
Note :- Remember this parameter is case sensitive. It is probably a good idea to then add a portmap line to hosts for security reasons
sudo nano /etc/hosts.allow
portmap : <NIS server IP address>
sudo update-rc.d portmap defaults 10
sudo nano /etc/yp.conf --- ubuntuserver.com  servername.ubuntuserver.com
sudo nano /etc/nisswitch.conf   --- nis
reboot
sudo nano /etc/pam.d/common-session
sudo sysv-rc-conf ypbind on
ypwhich
ypcat passwd
ypcat hosts
yppasswd

Error
1. sudo nisdomainname test.com
If you entered wrongly or want to change the default domain of NIS change it in the file then type.
2. sudo nano /etc/defaultdomain
3. Edit /etc/default/portmap and comment out the ARGS="-i 127.0.0.1" line