一、要使用 NFS 将 /media/usb1/video/ 目录以只读方式共享给特定的 IP 地址(例如 192.168.0.10),可以按照以下步骤进行配置:
安装 NFS 服务器:
sudo apt update
sudo apt install nfs-kernel-server
配置 NFS 导出:
编辑 /etc/exports 文件:
sudo nano /etc/exports
添加共享配置:
在文件末尾添加以下行:
# 共享给 XXX
/media/usb1/video 192.168.0.10/(rw,sync,no_subtree_check,no_root_squash)
这里:
ro 表示只读。
sync 确保数据在请求时同步写入。
no_subtree_check 提高性能并避免子目录检查。
no_root_squash 以允许客户端以 root 权限访问。
应用更改:
运行以下命令以应用新配置:
sudo exportfs -ra
检查 NFS 服务状态:
确保 NFS 服务正在运行:
sudo systemctl restart nfs-kernel-server
sudo systemctl status nfs-kernel-server
二、 UFW阻止了NFS的访问
现在需要做的是编辑/etc/nfs.conf并根据这个链接更新此配置:
[mountd]
取消注释行#port=0 并将端口替换为所需的数字(例如,在其他示例之后输入13025)
。
[mountd]
port=13025
重启服务器之后:
sudo systemctl restart nfs-server
打开你的防火墙端口2049、111、13025
sudo ufw allow from 192.168.0.0/24 to any port 2049 comment 'nfs-2049'
sudo ufw allow from 192.168.0.0/24 to any port 111 comment 'nfs-111'
sudo ufw allow from 192.168.0.0/24 to any port 13025 comment 'nfs-13025'
sudo ufw allow from 192.168.0.0/24 to any port 445 comment 'samba'
sudo ufw allow from 192.168.0.0/24 to any port 137 comment 'samba-NetBIOS 名称解析'
sudo ufw allow from 192.168.0.0/24 to any port 138 comment 'samba-数据报通信'
sudo ufw allow from 192.168.0.0/24 to any port 139 comment 'samba- SMB 协议'
确保端口13025现在已正确打开,并使用rpcinfo -p命令输出
评论 (0)