歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux管理 >> Linux配置 >> NFS啟動固定端口便於iptables配置

NFS啟動固定端口便於iptables配置

日期:2017/2/27 14:57:35   编辑:Linux配置
NFS啟動時會隨機啟動多個端口並向RPC注冊,這樣如果使用iptables對NFS端口進行限制就會有點麻煩,可以更改配置文件固定NFS服務相關端口。
如下NFS啟動後的端口:
[root@linux2 ~]# rpcinfo -p localhost
   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100011    1   udp    954  rquotad
    100011    2   udp    954  rquotad
    100011    1   tcp    957  rquotad
    100011    2   tcp    957  rquotad
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100021    1   udp  31718  nlockmgr
    100021    3   udp  31718  nlockmgr
    100021    4   udp  31718  nlockmgr
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100021    1   tcp  29916  nlockmgr
    100021    3   tcp  29916  nlockmgr
    100021    4   tcp  29916  nlockmgr
    100005    1   udp    990  mountd
    100005    1   tcp    993  mountd
    100005    2   udp    990  mountd
    100005    2   tcp    993  mountd
    100005    3   udp    990  mountd
    100005    3   tcp    993  mountd
分配端口,編輯配置文件
vi /etc/sysconfig/nfs
RQUOTAD_PORT=30001
LOCKD_TCPPORT=30002
LOCKD_UDPPORT=30002
MOUNTD_PORT=30003
STATD_PORT=30004
重啟portmap和nfs:
service portmap restart
service nfs restart
iptables設置:
iptables -I INPUT 5 -s 192.168.1.0/24 -p tcp -m state --state NEW -m tcp --dport 111 -j ACCEPT
iptables -I INPUT 6 -s 192.168.1.0/24 -p udp --dport 111 -j ACCEPT
iptables -I INPUT 7 -s 192.168.1.0/24 -p tcp -m state --state NEW -m tcp --dport 2049 -j ACCEPT
iptables -I INPUT 8 -s 192.168.1.0/24 -p udp --dport 2049 -j ACCEPT
iptables -I INPUT 9 -s 192.168.1.0/24 -p tcp -m state --state NEW -m tcp --dport 30001:30004 -j ACCEPT
iptables -I INPUT 10 -s 192.168.1.0/24 -p udp --dport 30001:30004 -j ACCEPT
Copyright © Linux教程網 All Rights Reserved