为什么不使用iptables来阻止这些你不想使用的端口(范围).确保将其作为拒绝规则并且不丢弃它,在后一种情况下可能需要更长时间,因为连接尝试超时.
典型规则可能如下所示:
/sbin/iptables -I OUTPUT -d 0/0 -j REJECT --reject-with icmp-net-prohibited -p tcp --dport XX -o ethX
/sbin/iptables -I OUTPUT -d 0/0 -j REJECT --reject-with icmp-net-prohibited -p udp --dport XX -o ethX
对于端口范围使用:
--dport XX:YY
对于传入:
/sbin/iptables -I INPUT -s 0/0 -j REJECT --reject-with icmp-net-prohibited -p tcp --dport XX -i ethX
/sbin/iptables -I INPUT -s 0/0 -j REJECT --reject-with icmp-net-prohibited -p udp --dport XX -i ethX
更新:可能从手册中为rpc.mountd添加正确的选项对您有用:
-p or --port num
Force rpc.mountd to bind to the specified port num, instead of using the random port number assigned by the portmapper.
在Debian中,您可以在/ etc / default / nfs-kernel-server中执行此操作,向此行添加选项:
# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information,
# see rpc.mountd(8) or http://wiki.debian.org/?SecuringNFS
RPCMOUNTDOPTS=--manage-gids