iptables dynamic port script for NFS
May 10, 2008
Some days ago I talked with a friend (here a link to his homepage) about firewalls and file servers and he told me he has a iptables script which adapts to the NFS ports automatically. I asked him for this script and here is it. Thx Hannes for the script.
# rpcinfo -p prints a list of all registered RPC programs
# sed -e '1D' removes the headline
# tr -s ' ' '\t' replaces repeated spaces with a single tab
# cut -f 4,5 we only need the protocol- and port-columns
# sort | uniq removes the duplicate lines
# now we have lines with the needed protocol and port but for splits
# this lines to single words so we have to store the protocol
for l in `rpcinfo -p | sed -e '1D' | tr -s ' ' '\t' | cut -f 4,5 | sort | uniq`
do
case $l in
tcp)
SYN=--syn
PROTOCOL=$l
;;
udp)
SYN=
PROTOCOL=$l
;;
*)
iptables -A INPUT -p $PROTOCOL --dport $l $SYN -j ACCEPT
;;
esac
done
1 Comment »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress
Entries and comments feeds.
Valid XHTML and CSS.
37 queries. 0.058 seconds.
very useful
it works really fine
thank you very much
best regard from Italy
Comment by Stefano — January 3, 2013 #