|
- yum install nfs-utils rpcbind
- mkdir -p /root/nfs_share
- #chmod 777 /root/nfs_share #网上的教程真坑,777非常危险,创建目录就行了,不要改权限
- vi /etc/exports
- /root/nfs_share *(rw,sync,no_root_squash)
- 这里为了省事,还是直接写成*吧,这样重启服务以后只需要配置防火墙就行
- 或者也可以写严格点
- /root/nfs_share 10.18.62.4/32(rw,sync,no_root_squash)
- 查看提供的目录信息
- exportfs -v
- systemctl start rpcbind
- systemctl start nfs-server
- systemctl enable rpcbind
- systemctl enable nfs-server
- 查看都使用了哪些端口
- rpcinfo -p
- 111/tcp
- 111/udp
- 33761/udp
- 53027/tcp
- 20048/tcp
- 20048/udp
- 2049/tcp
- 50227/udp #只重启nfs-server以后只有这2个端口变了,一般不需要重启的吧,上面配置好允许所有,以后只需要放行防火墙就行了
- 33565/tcp
- 然后是防火墙
- iptables -N INPUT_NFS___________________
- iptables -A INPUT_NFS___________________ -s 10.18.62.4 -m comment --comment "允许内网" -j ACCEPT
- iptables -A INPUT_NFS___________________ -s 114.103.167.5 -m comment --comment "允许抖音" -j ACCEPT
- iptables -A INPUT_NFS___________________ -j DROP
- iptables -A INPUT -p tcp -m multiport --dport 111,33761,20048,2049,33565 -m comment --comment "NFS" -j INPUT_NFS___________________
- iptables -A INPUT -p udp -m multiport --dport 111,33761,20048,50227 -m comment --comment "NFS" -j INPUT_NFS___________________
- 客户端的配置
- yum install nfs-utils
- 客户端一:
- 查看有哪些目录
- showmount -e 10.18.62.2
- 挂载
- mount -t nfs 10.18.62.2:/root/nfs_share /root/nfs_share
- 客户端二:
- 查看有哪些目录
- showmount -e 102.140.142.121
- 挂载
- mount -t nfs 102.140.142.121:/root/nfs_share /root/nfs_share
- 其他配置
- /etc/nfs.conf
- /etc/nfsmount.conf
- 这2个文件估计是需要仔细看的
- 然后网上的教程很多都不对
- 默认用的话按照我这个教程来就行了
复制代码
|
|