NFS服务固定端口设置,主要是为了开通防火墙策略,比如网闸
这里介绍常规的和非常规两种方式的配置
1.常规配置
vim /etc/sysconfig/nfs
RQUOTAD_PORT=30001
LOCKD_TCPPORT=30002
LOCKD_UDPPORT=30002
MOUNTD_PORT=30003
STATD_PORT=30004
固定的端口为30001-30004
vim /etc/modprobe.d/lockd.conf
options lockd nlm_tcpport=30002
options lockd nlm_udpport=30002
服务重启生效:
systemctl restart nfs-config
systemctl restart nfs-idmap
systemctl restart nfs-lock
systemctl restart nfs-server
2.非常规,主要是指没有配置文件/etc/sysconfig/nfs
vim /etc/services
rquotad 30001/tcp
rquotad 30001/tcp
lockd 30002/tcp
lockd 30002/udp
mountd 30003/tcp
mountd 30003/udp
statd 30004/tcp
statd 30004/udp
其中mountd 和rquotad需要注释掉原来的文件中的端口
#检查验证
netstat -anlp | grep -E 'tcp|udp'
若还有没修改的端口则修改下面的文件
vim /etc/nfs.conf
[statd]
port = 30004
[lockd]
port = 30002
#重启服务
systemctl restart nfs-config
systemctl restart nfs-idmap
systemctl restart nfs-lock
systemctl restart nfs-server
此处主要做个记录
------------------------------------------------------______________________________________
安全加固
思路:通过系统白名单和nfs配置来进行加固
1.修改nfs配置
cat /etc/exports
data 192.168.47.0/255.255.255.0(rw,sync,no_root_squash)
此处表示允许192.168.47.0/24这个网段访问,其他不允许访问
#重载配置
exportfs -avr
2.添加访问白名单和黑名单
cat /etc/hosts.allow
mountd:192.168.47.
rpcbind:192.168.47.:allow
portmap:192.168.47.
lockd:192.168.47.
rquotad:192.168.47.
statd:192.168.47.
#本机
portmap:127.0.0.1
lockd:1127.0.0.1
rquotad:127.0.0.1
statd:127.0.0.1
mountd:127.0.0.1
rpcbind:127.0.0.1:allow
192.168.47. 表示此网段可访问
cat /etc/hosts.deny
mountd:ALL
rpcbind:ALL:deny
statd:ALL
portmap:ALL
lockd:ALL
rquotad:ALL
3.验证
192.168.47网段机器访问:
rpcinfo server-ip
showmount -e server-ip
192.168.10网段机器访问:
rpcinfo server-ip
showmount -e server-ip
此处获取不到nfs的信息,也不能挂载即成功加固
_________________________________________________________________________________________
显示防火墙规则
firewall-cmd --list-all
防火墙加载nfs服务端口
firewall-cmd --permanent --add-service=nfs
重新加载防火墙规则
firewall-cmd --reload
标签:47,端口,192.168,server,etc,NFS,筑梦之路,nfs,restart From: https://www.cnblogs.com/jiyanfeng/p/16904893.html