====== Provide Network Shares To Specific Clients ====== **General Information** Configuring a NFS Server/Client. ---- ====== Lab Setup ====== The following virtual machines will be used: * server1.example.com (192.168.1.150) -> Perform all NFS client tests from here * server2.example.com (192.168.1.151) -> Install the NFS server here ---- ====== NFS Server: Install and Configure ====== Install required package yum install nfs-utils \\ Enable and start services systemctl enable nfs-server systemctl start nfs-server \\ Allow through the firewall # nfs -> allow mounting firewall-cmd --permanent --add-service=nfs firewall-cmd --reload # allow showmount -e firewall-cmd --permanent --add-service=rpc-bind firewall-cmd --permanent --add-service=mountd firewall-cmd --reload \\ Find SELinux boolean nfs export getsebool -a | grep nfs_export \\ Set SELinux booleans to on if they are not setsebool -P nfs_export_all_ro=1 nfs_export_all_rw=1 \\ Create the NFS common file and require IDMAPD for file sharing. vim /etc/default/nfs-common NEED_IDMAPD=YES * **NOT REQUIRED on 7.4**: No longer required in RHEL 7.4 (not sure what version this changed in) \\ Edit the domain in the idmapd.conf file vim /etc/idmapd.conf DOMAIN = server1.example.com * Edit domain as required for system * **NOT REQUIRED on 7.4**: No longer required in RHEL 7.4 (not sure what version this changed in) due to the default using the domain of the system exporting. \\ Create directories for exports mkdir /test1 /test2 \\ Give them the proper SELinux contexts semanage fcontext -at nfs_t "/test1(/.*)?" semanage fcontext -at nfs_t "/test2(/.*)?" restorecon -Rv /test1 restorecon -Rv /test2 \\ Edit export settings vim /etc/exports /test1 192.168.1.10(rw,no_root_squash) /test2 192.168.1.10(ro) \\ Export directories exportfs -var * -v -> verbose * -a -> all directories * -r -> Re-export all directories. (remove no longer valid entries) \\ Restart services systemctl restart nfs-server ---- ====== NFS Client: Install and Configure ====== Install required package yum install nfs-utils \\ Enable and start service systemctl enable rpcbind systemctl start rpcbind \\ **Optional**: Display the remove NFS server's available mounts showmount -e 192.168.1.200 \\ Create directories for mounting mkdir /test1 /test2 \\ Test a manual mount mount -t nfs -o rw 192.168.1.200:/test1 /test1 \\ Persistent mounts in fstab vim /etc/fstab 192.168.1.200:/test1 /test1 nfs rw,_netdev 0 0 192.168.1.200:/test2 /test2 nfs ro,_netdev 0 0 ----