Difference between revisions of "OPS335 NIS Lab"

From CDOT Wiki
Jump to: navigation, search
(OBJECTIVE & PREPARATION)
(Moved NIS config onto host so we don't have to worry about VMs being started in a specific order.)
Line 2: Line 2:
 
== OBJECTIVE & PREPARATION==
 
== OBJECTIVE & PREPARATION==
  
* Add a new user to your '''vm2''' with the same name as the one you created on '''vm3''' in lab 4b, but use a different password.
+
* Add a new user to your '''host''' with the same name as the one you created on '''vm3''' in lab 4b, but use a different password.
* Download and run the [http://matrix.senecac.on.ca/~peter.callaghan/files/OPS335/nfs.bash nfs.bash] script on each of your machines.  This will make '''vm2''' an nfs server sharing the home directories held there with the other vms.  It will also make the other vms automatically try to mount the home directories held on '''vm2''' into their own filesystem as soon as they boot.
+
* Download and run the [http://matrix.senecac.on.ca/~peter.callaghan/files/OPS335/nfs.bash nfs.bash] script on each of your machines.  This will make your '''host''' an nfs server sharing the home directories held there with the vms.  It will also make the vms automatically try to mount the home directories held on '''host''' into their own filesystem as soon as they boot.
 
* An NIS server is used to synchronize system files and other information between machines in an NIS domain.
 
* An NIS server is used to synchronize system files and other information between machines in an NIS domain.
* In this lab you will set a VM as an NIS server and share user information (names, groups, and passwords) with your other VM's.
+
* In this lab you will set your '''host''' as an NIS server and share user information (names, groups, and passwords) with your VM's.
 
{{Admon/important|Prerequisites|Before you begin make sure all your machines are up to date.
 
{{Admon/important|Prerequisites|Before you begin make sure all your machines are up to date.
 
Ensure both host and VM's have firewalls set up according to prior labs and all labs have been completed. }}
 
Ensure both host and VM's have firewalls set up according to prior labs and all labs have been completed. }}
Line 12: Line 12:
  
 
== INVESTIGATION 1: SETTING UP YOUR NIS SERVER ==
 
== INVESTIGATION 1: SETTING UP YOUR NIS SERVER ==
*Install the NIS server and client onto your VM 2.
+
*Install the NIS server and client onto your host.
 
   yum install ypserv ypbind
 
   yum install ypserv ypbind
 
*Add the following line to the bottom of the file /etc/sysconfig/network
 
*Add the following line to the bottom of the file /etc/sysconfig/network
Line 31: Line 31:
 
* Verify that your servers (NFS, ypserv) are running correctly with the following command:
 
* Verify that your servers (NFS, ypserv) are running correctly with the following command:
 
   rpcinfo -p
 
   rpcinfo -p
*At this step you should edit your firewalls to allow RPC and  NIS traffic through your firewall (Hint: check the output of rpcinfo -p or iptables traffic on the "lo" interface)
+
*At this step you should edit your firewalls to allow RPC and  NIS traffic through your firewall (Hint: check the output of rpcinfo -p or iptables traffic on the "lo" interface), but only if the traffic came from inside your virtual network.
 
*The machine will essentially be communicating with its own NIS server when using the Makefile
 
*The machine will essentially be communicating with its own NIS server when using the Makefile
 
*Now change to directory /var/yp and run this command to build the information databases
 
*Now change to directory /var/yp and run this command to build the information databases
Line 41: Line 41:
 
*Run 'ypcat passwd' again.
 
*Run 'ypcat passwd' again.
 
*Note that the new user does not appear.  In order for the new user to show up you will need to recreate the map files- change directory to /var/yp and run the "make" command again.
 
*Note that the new user does not appear.  In order for the new user to show up you will need to recreate the map files- change directory to /var/yp and run the "make" command again.
*Log out of '''VM2''', but leave it running
+
 
  
 
== INVESTIGATION 2: CLIENT CONFIGURATION ==
 
== INVESTIGATION 2: CLIENT CONFIGURATION ==
  
*Log into both '''vm2''' and '''vm3''' as the new user.  Note how they require different passwords on different machines.
+
*Log into both '''vm3''' as the new user.  Note how they require different passwords on different machines.
 
*Log out, and log back in as '''root''' (or use your normal user and '''su''') to continue.
 
*Log out, and log back in as '''root''' (or use your normal user and '''su''') to continue.
 
*Install ypbind on your vm3.
 
*Install ypbind on your vm3.
Line 51: Line 51:
 
  tail -f /var/log/messages
 
  tail -f /var/log/messages
 
*Edit /etc/yp.conf adding the following line:
 
*Edit /etc/yp.conf adding the following line:
  domain <learnid>.org server 192.168.x.3
+
  domain <learnid>.org server 192.168.x.1
*Add the following line to the bottom of the file /etc/sysconfig/network
 
  NISDOMAIN="<learn-id>.org"
 
 
*Start the ypbind server with the command.
 
*Start the ypbind server with the command.
 
  systemctl start ypbind.service
 
  systemctl start ypbind.service
Line 61: Line 59:
 
*You should be able to see the users from the server.
 
*You should be able to see the users from the server.
 
*If you added a mismatched user, you must update the map files on the server by running make again.
 
*If you added a mismatched user, you must update the map files on the server by running make again.
*Edit the /etc/nsswitch.conf file (on VM3 only) and change the following lines so they appear as below:
+
*Edit the /etc/nsswitch.conf file (on the VM only) and change the following lines so they appear as below:
 
  passwd:    nis files
 
  passwd:    nis files
 
  shadow:    nis files
 
  shadow:    nis files
Line 68: Line 66:
 
*Ensure ypbind will start at boot and restart the vm.
 
*Ensure ypbind will start at boot and restart the vm.
 
*Note that a recent bug is making machines with ypbind running take extraodinarily long to shut down.
 
*Note that a recent bug is making machines with ypbind running take extraodinarily long to shut down.
*Log into vm3 as the new user. You should now be able to use the password stored on '''vm2'''.
+
*Log into vm3 as the new user. You should now be able to use the password stored on '''host'''.
*Back on '''vm2''' change the password for the new user and rebuild the maps.  Try to log into '''vm3''' with the old password; it should now require the changed password.
+
*Back on '''host''' change the password for the new user and rebuild the maps.  Try to log into '''vm3''' with the old password; it should now require the changed password.
  
 
== INVESTIGATION 3: ADDING THE OTHER VMS ==
 
== INVESTIGATION 3: ADDING THE OTHER VMS ==
*When you have successfully made this change on '''vm3''', repeat these steps so that '''vm1''' will also use NIS for user identification from files located on '''vm2'''.
+
*When you have successfully made this change on '''vm3''', repeat these steps so that '''vm1''' and '''vm2'['' will also use NIS for user identification from files located on '''host'''.
 
**Warning:  When configuring the location of the NIS server to bind to, use the ip address instead of the hostname.  When the machine is booting, you have no guarantee that '''named''' starts before '''ypbind'''.
 
**Warning:  When configuring the location of the NIS server to bind to, use the ip address instead of the hostname.  When the machine is booting, you have no guarantee that '''named''' starts before '''ypbind'''.
  

Revision as of 10:20, 23 September 2016

OBJECTIVE & PREPARATION

  • Add a new user to your host with the same name as the one you created on vm3 in lab 4b, but use a different password.
  • Download and run the nfs.bash script on each of your machines. This will make your host an nfs server sharing the home directories held there with the vms. It will also make the vms automatically try to mount the home directories held on host into their own filesystem as soon as they boot.
  • An NIS server is used to synchronize system files and other information between machines in an NIS domain.
  • In this lab you will set your host as an NIS server and share user information (names, groups, and passwords) with your VM's.
Important.png
Prerequisites
Before you begin make sure all your machines are up to date. Ensure both host and VM's have firewalls set up according to prior labs and all labs have been completed.

Online Resources

INVESTIGATION 1: SETTING UP YOUR NIS SERVER

  • Install the NIS server and client onto your host.
 yum install ypserv ypbind
  • Add the following line to the bottom of the file /etc/sysconfig/network
 NISDOMAIN="<learn-id>.org"
 YPSERV_ARGS="-p 783"
  • This should be enough to set the domain name, however there is currently a bug in systemd that prevents this from working properly on its own.
    • You will also need to start and enable the rhel-domainname service.
  • Edit the file /etc/yp.conf and set up your domain:
 domain <learn-id>.org server 127.0.0.1
  • Create the file /var/yp/securenets:
 host 127.0.0.1
 255.255.255.0   192.168.x.0
  • Enable and start the NIS (ypserv) service.
systemctl start ypserv.service
systemctl enable ypserv.service
  • Backup the configuration file for NIS databases
 cp /var/yp/Makefile /var/yp/Makefile.orig
  • Verify that your servers (NFS, ypserv) are running correctly with the following command:
 rpcinfo -p
  • At this step you should edit your firewalls to allow RPC and NIS traffic through your firewall (Hint: check the output of rpcinfo -p or iptables traffic on the "lo" interface), but only if the traffic came from inside your virtual network.
  • The machine will essentially be communicating with its own NIS server when using the Makefile
  • Now change to directory /var/yp and run this command to build the information databases
 make
  • Enable and start the NIS binding (ypbind) service.
systemctl start ypbind.service
  • Use the following command to verify your NIS server is working - you should see your learnid password record.
 ypcat passwd
  • Run 'ypcat passwd' again.
  • Note that the new user does not appear. In order for the new user to show up you will need to recreate the map files- change directory to /var/yp and run the "make" command again.


INVESTIGATION 2: CLIENT CONFIGURATION

  • Log into both vm3 as the new user. Note how they require different passwords on different machines.
  • Log out, and log back in as root (or use your normal user and su) to continue.
  • Install ypbind on your vm3.
  • You may wish to follow the logs on vm3. In addition to your normal log in, ssh from the host to vm3 and get a continuous feed from the logs with:
tail -f /var/log/messages
  • Edit /etc/yp.conf adding the following line:
domain <learnid>.org server 192.168.x.1
  • Start the ypbind server with the command.
systemctl start ypbind.service
  • Looking at your logs ensure that ypbind is registered with rpcbind, if it is unable your firewall may need to be adjusted.
  • Now when you run the following command:
ypcat passwd
  • You should be able to see the users from the server.
  • If you added a mismatched user, you must update the map files on the server by running make again.
  • Edit the /etc/nsswitch.conf file (on the VM only) and change the following lines so they appear as below:
passwd:     nis files
shadow:     nis files
group:      nis files
  • Save and exit the file.
  • Ensure ypbind will start at boot and restart the vm.
  • Note that a recent bug is making machines with ypbind running take extraodinarily long to shut down.
  • Log into vm3 as the new user. You should now be able to use the password stored on host.
  • Back on host change the password for the new user and rebuild the maps. Try to log into vm3 with the old password; it should now require the changed password.

INVESTIGATION 3: ADDING THE OTHER VMS

  • When you have successfully made this change on vm3', repeat these steps so that vm1 and vm2'[ will also use NIS for user identification from files located on host.
    • Warning: When configuring the location of the NIS server to bind to, use the ip address instead of the hostname. When the machine is booting, you have no guarantee that named starts before ypbind.

Completing the Lab

You have now created an NIS server for your network and caused your other virtual machines to use it as a central repository for user information.

Depending on your professor you will either be asked to submit the lab in class, or online. Follow the appropriate set of instructions below.

Online Submission

Follow the instructions for lab 7 on moodle.

In Class Submission

Arrange evidence (command output) for each of these items on your screen, then ask your instructor to review them and sign off on the lab's completion:

To be completed by an instructor who uses in class submission.

EXPLORATION QUESTIONS

  1. What is the purpose of the rpcinfo command?
  2. Explain the purpose of the make command in the lab - what does it do?
  3. Explain the purpose of the /var/yp/securenets file.
  4. What is the function of the portmapper service?
  5. What ports did you need to open on your firewall?