Open main menu

CDOT Wiki β

Changes

OPS335 NFS Lab

2,283 bytes removed, 17:48, 4 March 2016
no edit summary
[[Category:OPS335]][[Category:OPS335 Labs]]
==FILE SERVER NFS RESOURCES==
Online References:
*[https://prezi.com/sfxdbjbxgu1e/file-servers-nsf-samba/ File Server Notes] (Week 9 class notes)
*[http://nfs.sourceforge.net/nfs-howto/ Linux NFS HOWTO]
*[http://tldp.org/HOWTO/NFS-HOWTO/security.html NSF Security] (List of tips regarding NSF and security)
In '''OPS235''', you learned how to install and configure an SSH server to be able to use utilities such as '''ssh''', '''scp''' and '''sftp'''. Although the '''sftp''' utility is useful for transferring files between different computers via the Internet, it is not considered useful or efficient for accessing files on servers that are connected over a local network.
Two popular protocols called '''Network File Server''' ('''NFS''') and '''Samba''' ('''SMB''') are used to provide high speed file access between servers on a local network. The '''NFS''' protocol allows a user to access files on another server in a local network in a similar way that local files on a same server are accessed. The '''Samba''' open-source software is used to access files from Windows servers using a combination of Windows protocols including NetBIOS, SMB, etc., and will be discussed in the next lab.
This lab will focus on installing, configuring and using '''NFS''' and '''Samba''' to access files between different Linux servers on a your local network.
==INVESTIGATION 1: USING AUTOMOUNT WITH '''NFS'''==
==INVESTIGATION 1: USING AUTOMOUNT WITH NFS== In this investigation, we will set up an '''NFS server''' on our '''VM2''' machine. We will then set up an '''NFS client''' on our <u>VM3</u> machine'''VM3so that we can ''' machine and be able to view and '''import filesof ''' within the VM2 's /home directories directory''' from the our <u>'''VM3 '''</u> machine.
{{Admon/important|Prerequistites|Due to the changes made in lab3, '''you will now need your vm1 running (as the DNS server)''' in order for any of your virtual machines to be able to use the internet.}}
#Make certain that all of your VMs are running.
#Switch to your '''VM2''' machine.
#Although nsf is the NFS application was already installed on your VM when you installed it, we will install additional utilities for nsf. Issue NFS by issuing the following command:<br>'''yum install nfs-utils'''#The '''/etc/exports''' file allows you to restrict the access to servers to access files for security purposes. Edit the '''/etc/exports''' file, and replace all contents of add the following line to the file with the following:<br>'''/home 192.168.x.4(rw,root_squash,insecure)'''#Start enable What does the IPADDR 192.168.x.4 represent? Record your answer in your nfs service lab logbook.#Issue the following command (now known as in order of appearance) in order to start your NFS server:<br>'''systemctl start rpcbind'''<br>'''systemctl start nfs-server.service''')#Use the '''systemctl''' command to enable both the rpcbind and nfs services upon VM startup.#Build Issue the following command in order to add (or "build") the server's list of permitted exports: <br>'''exportfs -r'''#Run and record the output of the following commandsin your lab logbook:<br>'''exportfs'''<br>'''showmount -e'''#You will have to adjust your firewall settings on your VM2 machine to allow NFS to work.<br>Run (Tip: run the '''netstat''' command in order to determine the <u>'''ports '''</u> needed and issue the appropriate ''iptables'' command(sor commands). Make certain to save your current iptables rules so they remain unchanged whey you reboot your NFS server and your client VM.
===Setting up &amp; Testing the NFS Client (VM3)===
'''Perform the following tasks:'''
#Ensure make certain that your '''VM3''' machine can connect to the VM guest network and that your '''VM1''' machine is functioning properly. You running as the DNS server (Tip: you can use the "host cbc.ca" command to see if DNS queries are being answered. #Ensure Make certain that you have full connectivity to the internetare logged into your '''VM3''' machine.#Again, you should not have to install any NFS softwareInstall the '''nfs-utils''' package on your '''VM3''' machine.
#Add the following line to the bottom of the '''/etc/fstab''' file on your VM3 machine:<br>'''192.168.x.3:/home /home nfs4 defaults 0 0'''
{{Admon/important|Warning:|Do not change any other lines in this file. |Do not change any lines in '''/etc/fstab on ''' file contained for your host VM3 machine. Doing so can make cause your VM3 machine fail not to bootproperly.}}<ol><li value="5">Run the following command to avoid an error confirm that would be caused by logging in while root_squash is activeSELinux will not block the network share:<br>'''setsebool -P'''<br>'''use_nfs_home_dirs 1'''</li><li>Logout of vm03 and shut it down.</li><li>Restart vm03 Issue the following command to mount any network shares without having to logout and login using to your learnid.</li><li>Check that the home directory is mountedVM3:<br>'''mount | grep /home-a'''</li><li>If it is not, try running Create an empty file within the regular user'mount /s home' as root and observe any errorsdirectory on your VM3 machine.</li><li>On vm03, create an empty file by issuing Issue the following ls-l command:for VM2 regular user's <bru>'''touch empty_file_created_on_vm03home'''</liu><li>Now shutdown vm03directory.Do you see a file that you created there?</li><li>Now Switch to your '''VM2''' machine and view the contents on the NFS server, us ls -l in your learnidregular user's <u>'''home '''</u> directory to check for the file . What you do you just creatednotice? What does this mean in terms of using NFS? Record your observations in your lab logbook.</li></olli===Setting up Automount (VM3)=== '''Perform the following tasks:Restart your VM3 machine''' #Switch to and login with your VM3 machineregular user id.#Comment or remove the line from </etc/fstab li><li>Make certain that you entered earlier.#With a server installation of Fedora 22, you will not need iptables rules are the same to allow NFS to install autofs, but on other installations you might need:work</li><brli>'''dnf install autof''Check that the VM3 regular user's#Move the existing file /etc/auto.master:<bru>'''mv /etc/auto.master /etc/auto.master.orighome'''#This is a great way to keep a back up in case you need to restore the file in the future. Now create another:<br/u>'''vi /etc/auto.master'''#Add only directory is mounted by issuing the following linecommand:<br>'''mount | grep /home /etc/auto.home --timeout=60'''#Create the file </etc/auto.home and add ONLY the following line:li><brli>If it is not, try running '''* -fstype=nfs4,rw,nosuid,soft 192.168.x.3:mount /home/&'''#Start autofs, as root and ensure the service will automatically start at bootobserve any errors.#Log out of vm3 and log back in using your learn account.#Open a terminal and enter the command:<br/li><li>'''mount | grep home'''#How does it differ from the previous mount?#Create another empty file with in the name:<br>regular user's home directory on your '''touch another_empty_file_from_vm03VM3'''#Run and record the output of the command:machine.</li><brli>Switch to your '''df -hTVM2'''#Back on the nfs server run and record the output of ls -l in your home directory.#You should machine to see the files if you created on vm03.#You may encounter errors with SELinux during the lab (though it has not been a problem recently). It is required can view that you leave it runningfile. #Use the following commands to determine what booleans need to be flipped:<br/li>'''audit2allow < /var/log/audit/audit.log'''<brli>Finally, issue the '''audit2why < /var/log/audit/audit.logls-l'''#Now that you have command in your VM3 automatically mounting regular user's home directories from VM2, configure VM1 directory to do note the samecontents.</li></ol>
'''Record steps, commands, and your observations in INVESTIGATION 1 in your OPS335 lab log-book'''
==INVESTIGATION 2: USING '''SAMBA''' TO ACCESS FILES SETTING UP AUTO-MOUNT ON WINDOWS SERVERSCLIENT (VM3)==
In this investigation, we will set be setting up to allow a '''Samba server''' network file share permanently on our '''VM2''' machineyour VMs. +++Complete this sentence +++
===Installing &amp; Configuring a Samba Server on Linux===*On your VM 2 install Samba dnf install samba samba-client*Create a backup of the file /etc/samba/smb.conf, and create a new one that includes only the following: [global] workgroup = <yourlearnid>.org server string = "put your real name here without the quotes" encrypt passwords = yes smb passwd file = /etc/samba/smbpasswd [home] comment = "put your real name here without the quotes" path = /home/<learnid> public = no writable = yes printable = no create mask = 0765*Now add a parameter to the global section that will limit access to the share so that only machines in your virtual network and those in the lab room will be able to access it.*Add a parameter to the home section so that only your user account can access that share.*Create a Samba password for user <learnid> with the command smbpasswd -a <learnid>*If you need to, you can change a user's password by using the command smbpasswd <username>*Confirm the user you created has been added using the following command pdbedit -L -v*Test and review your configuration with the command testparm*You can now start your Samba server (smb.service) and ensure it will start at boot. *Modify the firewall on VM2 to allow samba traffic.*Test if you have a connection with the command smbclient -U <learnid> -L vm2*It will show you a list of all available shares. ===Connecting to a Linux SMB Server from a Linux Client===There are many ways that a Linux client can connect to an SMB server. ==== Using smbclient ====*In a full installation you should not need to install samba-client on your host, but if it is not present then do so.*You will also need to install the cifs-utils package to be able to mount the filesystem.*From the host use the "smbclient" command in a terminal window. smbclient '\\vm2\home' -U <learnid>*After entering your password you should get a prompt similar to smb: \>*Enter the ls command to see a list of the files in your home directory - you may receive Perform the following error. smbtasks: \> ls NT_STATUS_ACCESS_DENIED listing \**SE Linux should be in Enforcing and will need to be adjusted (on the samba server) for this to work. setsebool -P samba_enable_home_dirs 1*Once you have access to the directory use the get and put commands (similar to ftp) to move files.*When you are finished close the connection. ==== Using 'mount -t cifs' ====*The next way is to use the mount command.*Use the mount command on the host to mount your home directory mkdir /tmp/vm2-home mount -t cifs //vm2/home /tmp/vm2-home -o username=<learnid> ls /tmp/vm2-home ==== Using Nautilus to browse Samba shares ====*Use the "Places" menu from the desktop and open 'Browse Network'.*From the menu in the side-bar of the files tool, choose 'Connect to Server'. *Enter 'smb://vm2/home' as the location, and enter your samba password in the prompt.**Where vm2 is the name of the server, and home is the name of the directory it is sharing.*After you have checked that you can access your files, unmount the share by right-clicking its icon in the side-bar and clicking 'Unmount'.
==== Using a browser ====#Switch to your '''VM3''' machine.#Unmount the /home directory from VM2 by running '''umount /home'''*You can also use a web browser with support for #Comment or remove the line that you added in the '''/etc/fstab''' file in the SMB protocol such as Konquerorprevious investigation.**Note that firefox does not have such support#Restart your '''VM3''' machine. *If Konqueror is not installed then install it with #Install the '''autofs''' package by issuing the following command: <br>'''yum install kdebaseautofs'''*Start Konqueror, #Rename the existing file '''/etc/auto.master''' file by issuing the webfollowing command:<br>'''mv /etc/auto.master /etc/auto.master.orig'''<br>Keep this file as a back-up in case you need to restore the file browser, and in the address bar enter future.#Use the vi text editor to create a new (empty) '''/etc/auto.master''' file and add the following smbline:<br>'''/home /vm2etc/auto.home --timeout=60'''*Enter #Save your username and password when promptedediting changes.*Double click on #Use the vi text editor to create a file you have some text incalled '''/etc/auto.home''' and add add the following line:<br>'''**Open it with gedit&nbsp; -fstype=nfs4,rw,nosuid, make some soft &nbsp; 192.168.x.3:/home/&'''#Save your editing changes, and save it.**When prompted#Use the '''systemctl''' command to start the '''autofs''' service, choose and another systemctl command in order to upload ensure that the fileautofs service will automatically start at boot.*Close Konqueror#Log out of and back into '''vm3''' using your <u>regular</u> user account (i.e. not root. You should be in your regular user account for both VM2 and VM3 machines).*cat #Open a terminal and enter the following command:<br>'''mount | grep home'''#How does it differ from the previous mount? Record your findings in your lab logbook.#On your '''VM3''' machine, create another empty file with the name:<br>'''touch yet_another_empty_file_from_vm3'''#Run and record the output of the following command (on both your VM2 and VM3 machines):<br>'''df -hT'''#Switch to the nfs server ('''vm2'''), run and record the output of '''ls -l''' in your home directory (You should see the files you created on vm3).#Now that you have VM3 automatically mounting home directories from your VM2 machine, repeat the steps in this investigation in order to configure your '''VM1''' machine to ensure do the changes were properly uploadedsame.
====Connecting to a Linux SMB Server from a Windows Client (Windows 7)====
*Power up a Windows 7 system in the lab and login using your LEARN username and password.
*Add the prerouting and forwarding rules to your Centos host's iptables necessary to redirect samba traffic from outside your network to your VM 2.
*Open up Explorer and Right click on Computer > Map network drive.. > Select a Drive Letter and '\\<ip-address-of-host>\home' > you will then be asked for your username and password.
*You should now be able to browser, drag and drop your files to and from the Windows machine.
'''Record steps, commands, and your observations in INVESTIGATION 2 in your OPS335 lab log-book'''
==COMPLETING THE LAB==
'''Arrange proof that ...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:'''
::<span style="color:green;font-size:1.5em;">&#x2713;</span> Show mount information regarding vm3 and vm1 shares with NFS server (vm2)
::<span style="color:green;font-size:1.5em;">&#x2713;</span> All files shown in network server (vm2)
::<span style="color:green;font-size:1.5em;">&#x2713;</span> Display contents of '''/etc/exports''', '''/etc/auto.master''' and '''/etc/auto.home''' files
::<span style="color:green;font-size:1.5em;">&#x2713;</span> Lab logbook completed
==EXPLORATION QUESTIONS==
#What is the role of the /etc/mtab file on the nfs server?
#What port does nfs-server use?
#What is the purpose of the testparm command?
#What does SMB stand for? CIFS?
#What does the text inside square brackets in the smb.conf file mean? (e.g., "[home]").
#Explain the meaning of the line "create mask = 0765" in the smb.conf file?
#What does the smbpasswd command do?
#What did the setsebool command do?
13,420
edits