To allow NFS clients to access an NFS server through a Linux firewall using iptables, you will need to open the ports that are used by NFS.
NFS uses the following ports:
To allow NFS clients to access an NFS server through a Linux firewall using iptables, you can use the following steps:
iptables -A INPUT -p tcp --dport 2049 -j ACCEPT iptables -A INPUT -p udp --dport 2049 -j ACCEPT iptables -A INPUT -p tcp --dport 111 -j ACCEPT iptables -A INPUT -p udp --dport 111 -j ACCEPT
service iptables save
This will allow incoming connections on the NFS ports, and allow NFS clients to access the NFS server through the firewall.
Note: These steps will allow all incoming connections on the NFS ports. If you want to restrict access to specific IP addresses or subnets, you can use the
-soption to specify the source IP address or subnet. For example:
iptables -A INPUT -p tcp -s 192.168.1.0/24 --dport 2049 -j ACCEPT
This will allow incoming connections on port 2049 from the 192.168.1.0/24 subnet.
It's a good idea to regularly review and update your firewall rules to ensure that they are secure and up to date. You can use tools such as iptables-save and iptables-restore to manage and backup your firewall rules.