How to write iptables rules for NFS shared servers on CentOS 7

Source: Internet
Author: User

In order to write iptables rules, this port must be fixed to better use, so in/usr/lib/systemd/scripts/nfs-utils_env.sh found a very interesting thing

 

So I directly wrote the sysctl file.

Echo-e '### nfs add \ nfs. nfs. nlm_tcpport = 32803 \ nfs. nfs. nlm_udpport = 32769'>/etc/sysctl. conf
Sysctl-p

Then I tried again and found that the port was fixed. I went there, and it was quite fun.
Then you can directly create iptables rules later.

Iptables-N NFS
Iptables-r input 8-p udp-m state -- state NEW-m multiport -- dports $ (rpcinfo-p | awk 'NR> 1 & $3 ~ /Udp /&&! A [$4] ++ {c = c? C "," $4: $4} END {print c} ')-j NFS
Iptables-r input 7-p tcp-m state -- state NEW-m multiport -- dports $ (rpcinfo-p | awk 'NR> 1 & amp; $3 ~ /Tcp /&&! A [$4] ++ {c = c? C "," $4: $4} END {print c} ')-j NFS
Iptables-I NFS-s 10.0.0.0/8-p tcp-j ACCEPT
Iptables-a nfs-s 10.0.0.0/8-p udp-j ACCEPT

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.