#!/bin/bash
echo this bash file is for nfs :
echo nfs-utils-1.0.9-40.el5 nfs-utils-lib-1.0.8-7.2.z2
echo your current nfs version is :
echo `rpm -aq|grep nfs`
#---iptables
service iptables restart
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
echo ----------restart portmap---------
service portmap restart
echo -----------restart nfs------------
service nfs restart
#service nfslock restart
tcports=`rpcinfo -p localhost | awk '$3~/tcp/{ print $4 }'|uniq`
udports=`rpcinfo -p localhost | awk '$3~/udp/{ print $4 }'|uniq`
tcports=`echo $tcports|sed 's/ /,/g'`
udports=`echo $udports|sed 's/ /,/g'`
iptables -N nfs-in
iptables -N nfs-out
iptables -A nfs-in -p tcp -m multiport --dport $tcports -j ACCEPT
iptables -A nfs-in -p udp -m multiport --dport $udports -j ACCEPT
iptables -A nfs-out -p tcp -m multiport --sport $tcports -j ACCEPT
iptables -A nfs-out -p udp -m multiport --sport $udports -j ACCEPT
iptables -A INPUT -j nfs-in
iptables -A OUTPUT -j nfs-out