Can anyone provide the exact wording/coding I would have to add to my /etc/iptables/rules.v4 file ? The server I am working on has many complicated firewall rules, and I have determined it is for sure the iptables preventing the nfs mount as I can mount if the iptables are down. My NFS version is 4. As I understand ports 111 and 2049 need to allow traffic, but I feel I am not typing the rules correctly. The share is over a private network. The NFS share's IP is, and the private IP of the 16.04 server is

NOTE: There are several filters in place so any advice on where exactly to place the rules is much appreciated.

I have tried these two seperate answers found on the net will no joy.

# Portmap ports
-A INPUT -m state –state NEW -p tcp –dport 111 -j ACCEPT    
-A INPUT -m state –state NEW -p udp –dport 111 -j ACCEPT    
# NFS daemon ports    
-A INPUT -m state –state NEW -p tcp –dport 2049 -j ACCEPT    
-A INPUT -m state –state NEW -p udp –dport 2049 -j ACCEPT    

The other is

 iptables -P INPUT DROP    
   iptables -P OUTPUT DROP    
   iptables -A INPUT -s -d -p udp -m multiport --sports 10053,111,2049,32769,875,892 -m state --state ESTABLISHED -j ACCEPT 
   iptables -A INPUT -s -d -p tcp -m multiport --sports 10053,111,2049,32803,875,892 -m state --state ESTABLISHED -j ACCEPT 
   iptables -A OUTPUT -s -d -p udp -m multiport --dports 10053,111,2049,32769,875,892 -m state --state NEW,ESTABLISHED -j ACCEPT 
   iptables -A OUTPUT -s -d -p tcp -m multiport --dports 10053,111,2049,32803,875,892 -m state --state NEW,ESTABLISHED -j ACCEPT 
   iptables -I INPUT  -i lo -d -j ACCEPT
   iptables -I OUTPUT  -o lo -s -j ACCEPT
   iptables -L -n --line-numbers    

Using my own IP instead of what is in the above example.

1 Answer 1


Here is what worked for me for future askers.

-A INPUT -s -d -i eth0 -p tcp --sport 111 -j ACCEPT
-A INPUT -s -d -i eth0 -p tcp --sport 2049 -j ACCEPT
-A INPUT -s -d -i eth0 -p udp --sport 111 -j ACCEPT
-A INPUT -s -d -i eth0 -p udp --sport 2049 -j ACCEPT
-A OUTPUT -s -d -o eth0 -p tcp --dport 111 -j ACCEPT
-A OUTPUT -s -d -o eth0 -p tcp --dport 2049 -j ACCEPT
-A OUTPUT -s -d -o eth0 -p udp --dport 111 -j ACCEPT
-A OUTPUT -s -d -o eth0 -p udp --dport 2049 -j ACCEPT

IP = .40 being client and .25 being the server. .25 being mounted onto the .40. If this can be done with less rules, then in the future I hope someone finds that answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .