LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > Linux配置 >

NFS启动固定端口便于iptables配置

时间:2013-09-11 11:49来源:未知 编辑:linuxeye 点击:
NFS启动时会随机启动多个端口并向RPC注册,这样如果使用iptables对NFS端口进行限制就会有点麻烦,可以更改配置文件固定NFS服务相关端口。 如下NFS启动后的端口: [root@linux2 ~]# rpcinfo -p
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

转载请保留固定链接: https://linuxeye.com/configuration/1920.html

------分隔线----------------------------
标签:iptablesnfs
栏目列表
推荐内容