Friday, March 25, 2011

Setup Simple NFS server

/etc/sysconfig/nfs
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
STATD_PORT=662
STATD_OUTGOING_PORT=2020

Open ports needed by nfs server in iptables
#NFS
iptables -A custom-fw-input -p tcp -m state --state NEW -m tcp --dport 111 -j ACCEPT
iptables -A custom-fw-input -p udp -m state --state NEW -m udp --dport 111 -j ACCEPT
iptables -A custom-fw-input -p tcp -m state --state NEW -m tcp --dport 2049 -j ACCEPT
iptables -A custom-fw-input -p udp -m state --state NEW -m udp --dport 2049 -j ACCEPT
iptables -A custom-fw-input -p udp -m state --state NEW -m udp --dport 32803 -j ACCEPT
iptables -A custom-fw-input -p tcp -m state --state NEW -m tcp --dport 32769 -j ACCEPT
iptables -A custom-fw-input -p tcp -m state --state NEW -m tcp --dport 892 -j ACCEPT
iptables -A custom-fw-input -p tcp -m state --state NEW -m tcp --dport 662 -j ACCEPT
iptables -A custom-fw-input -p tcp -m state --state NEW -m tcp --dport 2020 -j ACCEPT

Publish the path on which we will share thru NFS. From this example,/var/www/html/yum/rpms

root@rhel01.localdomain: ~ # cat /etc/exports
/var/www/html/yum/rpms/ *(ro,sync)
root@rhel01.localdomain: ~ # exportfs -a

Restart the services
for i in rpcbind nfs nfslock ; do service $i restart; done

Test the nfs share using showmount and mount commands
root@rhel02.localdomain: / # showmount -e rhel01
Export list for rhel01:
/var/www/html/yum/rpms *
root@rhel02.localdomain: / # mount rhel01:/var/www/html/yum/rpms /mnt
root@rhel02.localdomain: / # df -k /mnt
Filesystem 1K-blocks Used Available Use% Mounted on
rhel01:/var/www/html/yum/rpms
10321280 3402752 6394240 35% /mnt

No comments:

Post a Comment