Network File System - allows remote hosts to mount file systems over the network. We will be setting up a NFS server and client in this post.
NFS SERVER:
First you will have to install packages
# yum groupinstall "NFS file server"
Open Firewall Ports TCP 2049, TCP 111, UDP 111
# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
:wq
# service iptables restart
Start your services for NFS
# service rpcbind start
# service nfslock start
# service nfs start
Let us make our services persistent to reboot
# chkconfig rpcbind on
# chkconfig nfslock on
# chkconfig nfs on
Now we can create our share directories, if you have one that is even better
# mkdir -p /home/testshare
We will enter desired directory to share in the /etc/exports file
# vim /etc/exports
/home/testshare nfsclient(rw,no_root_squash)
:wq
Export the directory
# exportfs -avr
NFS CLIENT:
Install basic services for nfs client also, in my case I have again groupinstalled all the packages (just lazy)
$ Start the services
$ Make them persistent to reboot
# mount -t nfs 192.168.122.50:/home/testshare /nfsclientdir
# cd /nfsclientdir
Do not forget to enter mount information to the /etc/fstab file to make it persistent to reboot
# vim /etc/fstab
192.168.122.50:/home/testshare /nfsclientdir nfs _netdev 0 0
:wq
* _netdev option is for system not to try to mount the filesystem until nfs service started after boot. (will prevent boot time hanging)
Now you have access to the folder that has been shared, and you will have read and write permissions.
NFS SERVER:
First you will have to install packages
# yum groupinstall "NFS file server"
Open Firewall Ports TCP 2049, TCP 111, UDP 111
# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
:wq
# service iptables restart
Start your services for NFS
# service rpcbind start
# service nfslock start
# service nfs start
Let us make our services persistent to reboot
# chkconfig rpcbind on
# chkconfig nfslock on
# chkconfig nfs on
Now we can create our share directories, if you have one that is even better
# mkdir -p /home/testshare
We will enter desired directory to share in the /etc/exports file
# vim /etc/exports
/home/testshare nfsclient(rw,no_root_squash)
:wq
Export the directory
# exportfs -avr
NFS CLIENT:
Install basic services for nfs client also, in my case I have again groupinstalled all the packages (just lazy)
$ Start the services
$ Make them persistent to reboot
# mount -t nfs 192.168.122.50:/home/testshare /nfsclientdir
# cd /nfsclientdir
Do not forget to enter mount information to the /etc/fstab file to make it persistent to reboot
# vim /etc/fstab
192.168.122.50:/home/testshare /nfsclientdir nfs _netdev 0 0
:wq
* _netdev option is for system not to try to mount the filesystem until nfs service started after boot. (will prevent boot time hanging)
Now you have access to the folder that has been shared, and you will have read and write permissions.
No comments:
Post a Comment