{"id":6101,"date":"2016-07-31T16:22:01","date_gmt":"2016-07-31T08:22:01","guid":{"rendered":"http:\/\/rmohan.com\/?p=6101"},"modified":"2016-07-31T16:22:01","modified_gmt":"2016-07-31T08:22:01","slug":"setting-up-a-local-nfs-server","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6101","title":{"rendered":"SETTING UP A LOCAL NFS SERVER"},"content":{"rendered":"<p>On the NFS Server, we will need to install the following packages:<\/p>\n<p>yum -y install portreserve quota rpcbind nfs4-acl-tools.x86_64 nfs-utils.x86_64<br \/>\n# service rpcbind start<br \/>\n# chkconfig rpcbind on<br \/>\n# service nfs start<br \/>\n# chkconfig nfs on<br \/>\nThe next step is to make the physical mount point (in this example, it\u2019s \/ilovecoco). We then need to update the \/etc\/exports file.  Add the physical mount point we just created, and then add the IP address of the remote machine with any mapping options (in this example, we added rw,sync as mount options).<\/p>\n<p>[root@memberserver ~]# mkdir \/ilovecoco<br \/>\n[root@memberserver ~]# vi \/etc\/exports<br \/>\n[root@memberserver ~]# cat \/etc\/exports<br \/>\n\/ilovecoco 192.168.56.102(rw,sync)<br \/>\nMake the export file active by issuing the following commands:<\/p>\n<p>[root@memberserver ~]# exportfs -r<br \/>\n[root@memberserver ~]# exportfs -a<br \/>\nOn the server, we can now verify that the NFS mount is active by issuing the following command:<\/p>\n<p>[root@memberserver ~]# showmount -e<br \/>\nExport list for memberserver:<br \/>\n\/ilovecoco 192.168.56.102<br \/>\nWe can now try and access this NFS share from a remote host.<\/p>\n<p>[root@master ~]# showmount -e 192.168.56.103<br \/>\nclnt_create: RPC: Port mapper failure &#8211; Unable to receive: errno 113 (No route to host)<br \/>\nThe above error message is a result of the firewall blocking access. Firewall access now needs to be setup. For the purposes of testing, I enabled ALL ports on the firewall.<\/p>\n<p>[root@localhost ~]# iptables -F<br \/>\n[root@localhost ~]# iptables -A INPUT -j ACCEPT<br \/>\n[root@localhost ~]# iptables-save<br \/>\n# Generated by iptables-save v1.4.21 on Wed Oct 22 19:29:57 2014<br \/>\n*nat<br \/>\n:PREROUTING ACCEPT [984:75513]<br \/>\n:INPUT ACCEPT [4:234]<br \/>\n:OUTPUT ACCEPT [1209:57593]<br \/>\n:POSTROUTING ACCEPT [1209:57593]<br \/>\n:OUTPUT_direct &#8211; [0:0]<br \/>\n:POSTROUTING_ZONES &#8211; [0:0]<br \/>\n:POSTROUTING_ZONES_SOURCE &#8211; [0:0]<br \/>\n:POSTROUTING_direct &#8211; [0:0]<br \/>\n:POST_public &#8211; [0:0]<br \/>\n:POST_public_allow &#8211; [0:0]<br \/>\n:POST_public_deny &#8211; [0:0]<br \/>\n:POST_public_log &#8211; [0:0]<br \/>\n:PREROUTING_ZONES &#8211; [0:0]<br \/>\n:PREROUTING_ZONES_SOURCE &#8211; [0:0]<br \/>\n:PREROUTING_direct &#8211; [0:0]<br \/>\n:PRE_public &#8211; [0:0]<br \/>\n:PRE_public_allow &#8211; [0:0]<br \/>\n:PRE_public_deny &#8211; [0:0]<br \/>\n:PRE_public_log &#8211; [0:0]<br \/>\n-A PREROUTING -j PREROUTING_direct<br \/>\n-A PREROUTING -j PREROUTING_ZONES_SOURCE<br \/>\n-A PREROUTING -j PREROUTING_ZONES<br \/>\n-A OUTPUT -j OUTPUT_direct<br \/>\n-A POSTROUTING -j POSTROUTING_direct<br \/>\n-A POSTROUTING -j POSTROUTING_ZONES_SOURCE<br \/>\n-A POSTROUTING -j POSTROUTING_ZONES<br \/>\n-A POSTROUTING_ZONES -o enp0s8 -g POST_public<br \/>\n-A POSTROUTING_ZONES -o enp0s3 -g POST_public<br \/>\n-A POSTROUTING_ZONES -g POST_public<br \/>\n-A POST_public -j POST_public_log<br \/>\n-A POST_public -j POST_public_deny<br \/>\n-A POST_public -j POST_public_allow<br \/>\n-A PREROUTING_ZONES -i enp0s8 -g PRE_public<br \/>\n-A PREROUTING_ZONES -i enp0s3 -g PRE_public<br \/>\n-A PREROUTING_ZONES -g PRE_public<br \/>\n-A PRE_public -j PRE_public_log<br \/>\n-A PRE_public -j PRE_public_deny<br \/>\n-A PRE_public -j PRE_public_allow<br \/>\nCOMMIT<br \/>\n# Completed on Wed Oct 22 19:29:57 2014<br \/>\n# Generated by iptables-save v1.4.21 on Wed Oct 22 19:29:57 2014<br \/>\n*mangle<br \/>\n:PREROUTING ACCEPT [7214:4652078]<br \/>\n:INPUT ACCEPT [7212:4650926]<br \/>\n:FORWARD ACCEPT [0:0]<br \/>\n:OUTPUT ACCEPT [5282:434260]<br \/>\n:POSTROUTING ACCEPT [5312:439910]<br \/>\n:FORWARD_direct &#8211; [0:0]<br \/>\n:INPUT_direct &#8211; [0:0]<br \/>\n:OUTPUT_direct &#8211; [0:0]<br \/>\n:POSTROUTING_direct &#8211; [0:0]<br \/>\n:PREROUTING_ZONES &#8211; [0:0]<br \/>\n:PREROUTING_ZONES_SOURCE &#8211; [0:0]<br \/>\n:PREROUTING_direct &#8211; [0:0]<br \/>\n:PRE_public &#8211; [0:0]<br \/>\n:PRE_public_allow &#8211; [0:0]<br \/>\n:PRE_public_deny &#8211; [0:0]<br \/>\n:PRE_public_log &#8211; [0:0]<br \/>\n-A PREROUTING -j PREROUTING_direct<br \/>\n-A PREROUTING -j PREROUTING_ZONES_SOURCE<br \/>\n-A PREROUTING -j PREROUTING_ZONES<br \/>\n-A INPUT -j INPUT_direct<br \/>\n-A FORWARD -j FORWARD_direct<br \/>\n-A OUTPUT -j OUTPUT_direct<br \/>\n-A POSTROUTING -j POSTROUTING_direct<br \/>\n-A PREROUTING_ZONES -i enp0s8 -g PRE_public<br \/>\n-A PREROUTING_ZONES -i enp0s3 -g PRE_public<br \/>\n-A PREROUTING_ZONES -g PRE_public<br \/>\n-A PRE_public -j PRE_public_log<br \/>\n-A PRE_public -j PRE_public_deny<br \/>\n-A PRE_public -j PRE_public_allow<br \/>\nCOMMIT<br \/>\n# Completed on Wed Oct 22 19:29:57 2014<br \/>\n# Generated by iptables-save v1.4.21 on Wed Oct 22 19:29:57 2014<br \/>\n*security<br \/>\n:INPUT ACCEPT [6204:4571149]<br \/>\n:FORWARD ACCEPT [0:0]<br \/>\n:OUTPUT ACCEPT [5282:434260]<br \/>\n:FORWARD_direct &#8211; [0:0]<br \/>\n:INPUT_direct &#8211; [0:0]<br \/>\n:OUTPUT_direct &#8211; [0:0]<br \/>\n-A INPUT -j INPUT_direct<br \/>\n-A FORWARD -j FORWARD_direct<br \/>\n-A OUTPUT -j OUTPUT_direct<br \/>\nCOMMIT<br \/>\n# Completed on Wed Oct 22 19:29:57 2014<br \/>\n# Generated by iptables-save v1.4.21 on Wed Oct 22 19:29:57 2014<br \/>\n*raw<br \/>\n:PREROUTING ACCEPT [7241:4653776]<br \/>\n:OUTPUT ACCEPT [5282:434260]<br \/>\n:OUTPUT_direct &#8211; [0:0]<br \/>\n:PREROUTING_direct &#8211; [0:0]<br \/>\n-A PREROUTING -j PREROUTING_direct<br \/>\n-A OUTPUT -j OUTPUT_direct<br \/>\nCOMMIT<br \/>\n# Completed on Wed Oct 22 19:29:57 2014<br \/>\n# Generated by iptables-save v1.4.21 on Wed Oct 22 19:29:57 2014<br \/>\n*filter<br \/>\n:INPUT ACCEPT [0:0]<br \/>\n:FORWARD ACCEPT [0:0]<br \/>\n:OUTPUT ACCEPT [17:1800]<br \/>\n:FORWARD_IN_ZONES &#8211; [0:0]<br \/>\n:FORWARD_IN_ZONES_SOURCE &#8211; [0:0]<br \/>\n:FORWARD_OUT_ZONES &#8211; [0:0]<br \/>\n:FORWARD_OUT_ZONES_SOURCE &#8211; [0:0]<br \/>\n:FORWARD_direct &#8211; [0:0]<br \/>\n:FWDI_public &#8211; [0:0]<br \/>\n:FWDI_public_allow &#8211; [0:0]<br \/>\n:FWDI_public_deny &#8211; [0:0]<br \/>\n:FWDI_public_log &#8211; [0:0]<br \/>\n:FWDO_public &#8211; [0:0]<br \/>\n:FWDO_public_allow &#8211; [0:0]<br \/>\n:FWDO_public_deny &#8211; [0:0]<br \/>\n:FWDO_public_log &#8211; [0:0]<br \/>\n:INPUT_ZONES &#8211; [0:0]<br \/>\n:INPUT_ZONES_SOURCE &#8211; [0:0]<br \/>\n:INPUT_direct &#8211; [0:0]<br \/>\n:IN_public &#8211; [0:0]<br \/>\n:IN_public_allow &#8211; [0:0]<br \/>\n:IN_public_deny &#8211; [0:0]<br \/>\n:IN_public_log &#8211; [0:0]<br \/>\n:OUTPUT_direct &#8211; [0:0]<br \/>\n-A INPUT -j ACCEPT<br \/>\nCOMMIT<br \/>\n# Completed on Wed Oct 22 19:29:57 2014<br \/>\n[root@master ~]# showmount -e 192.168.56.103<br \/>\nExport list for 192.168.56.103:<br \/>\n\/ilovecoco 192.168.56.102<br \/>\nLets now try manually mapping up this mount using the mount command.<\/p>\n<p>[root@master ~]# mkdir \/ialsolovesnooki<br \/>\n[root@master ~]# mount 192.168.56.103:\/ilovecoco \/ialsolovesnooki<br \/>\n[root@master ~]# df -hk | grep \/ialsolovesnooki<br \/>\n192.168.56.103:\/ilovecoco   7022592 1447680   5574912  21% \/ialsolovesnooki<br \/>\n[root@master ~]# ls -lrt \/ialsolovesnooki<br \/>\ntotal 0<br \/>\n-rw-r&#8211;r&#8211;. 1 root root 0 Oct 23  2014 mycatsarethebest<br \/>\nLets now get fancy and map this mount on demand using the autofs auto mounting daemon service. We\u2019ll need to install autofs first.<\/p>\n<p>[root@master ~]# yum -y install autofs<br \/>\n[root@master ~]# service autofs start<br \/>\nRedirecting to \/bin\/systemctl start  autofs.service<br \/>\n[root@master ~]# chkconfig autofs on<br \/>\nNote: Forwarding request to &#8216;systemctl enable autofs.service&#8217;.<br \/>\nWe also need to install nfs-utils and nfs4-acl-tools on the client host:<\/p>\n<p>[root@localhost ~]# yum -y install nfs-utils.x86_64 nfs4-acl-tools.x86_64<br \/>\n\/etc\/auto.misc has several helpful examples which we will draw inspiration from to mount our NFS share. The line which we are interested in is the #linux line.<\/p>\n<p>[root@slave \/]# cat \/etc\/auto.misc<br \/>\n#<br \/>\n# This is an automounter map and it has the following format<br \/>\n# key [ -mount-options-separated-by-comma ] location<br \/>\n# Details may be found in the autofs(5) manpage<br \/>\ncd              -fstype=iso9660,ro,nosuid,nodev :\/dev\/cdrom<br \/>\n# the following entries are samples to pique your imagination<br \/>\n#linux          -ro,soft,intr           ftp.example.org:\/pub\/linux<br \/>\n#boot           -fstype=ext2            :\/dev\/hda1<br \/>\n#floppy         -fstype=auto            :\/dev\/fd0<br \/>\n#floppy         -fstype=ext2            :\/dev\/fd0<br \/>\n#e2floppy       -fstype=ext2            :\/dev\/fd0<br \/>\n#jaz            -fstype=ext2            :\/dev\/sdc1<br \/>\n#removable      -fstype=ext2            :\/dev\/hdd<br \/>\nLets now edit the master mapping file.<\/p>\n<p>[root@slave \/]# vi \/etc\/auto.master<br \/>\n\/meow \/etc\/auto.coco<br \/>\nIt\u2019s important to ensure that the filename begins in auto. It can end in anything, i.e. auto.duck.<\/p>\n<p>[root@localhost meow]# vi \/etc\/auto.coco<br \/>\nreow          -ro,soft,intr           192.168.56.103:\/ilovecoco<br \/>\nRestart autofs.<\/p>\n<p>[root@localhost meow]# service autofs restart<br \/>\nRedirecting to \/bin\/systemctl restart  autofs.service<br \/>\nNow try and access the mount:<\/p>\n<p>[root@localhost meow]# cd \/<br \/>\n[root@localhost \/]# cd meow<br \/>\n[root@localhost meow]# cd reow<br \/>\n[root@localhost reow]# ls -lrt<br \/>\ntotal 0<br \/>\n-rwxrwxrwx. 1 root root 0 Oct 22 19:57 mycatsarethebest<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On the NFS Server, we will need to install the following packages:<\/p>\n<p>yum -y install portreserve quota rpcbind nfs4-acl-tools.x86_64 nfs-utils.x86_64 # service rpcbind start # chkconfig rpcbind on # service nfs start # chkconfig nfs on The next step is to make the physical mount point (in this example, it\u2019s \/ilovecoco). We then need to [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6101"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6101"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6101\/revisions"}],"predecessor-version":[{"id":6102,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6101\/revisions\/6102"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}