配置

配置

在 Ubuntu 17.04 版本上,我的 NFS 共用定義如下:

配置

/etc/exports

/bottle/media 192.168.0.0/16(ro,all_squash,no_subtree_check,anonuid=65534,anongid=65534) 10.3.0.0/16(rw,all_squash,sync,no_subtree_check,anonuid=65534,anongid=65534)

共享磁碟區的 UNIX 檔案權限:

$ ls -al /bottle
total 5
drwxr-xr-x  3 root   root       3 Sep  3 11:45 .
drwxr-xr-x 28 root   root    4096 Sep  3 00:37 ..
drwxrwxr-x  2 nobody nogroup    2 Sep  3 11:45 media

確認

sudo exportfs

/bottle/media   192.168.0.0/16
/bottle/media   10.3.0.0/24

檢查 NFS 伺服器守護進程:

$ sudo systemctl status nfs-server
● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sun 2017-09-03 12:09:47 BST; 16min ago
  Process: 23350 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
  Process: 23344 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
  Process: 23337 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
  Process: 23380 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 23374 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 23380 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   Memory: 0B
      CPU: 0
   CGroup: /system.slice/nfs-server.service

Sep 03 12:09:47 monolith systemd[1]: Starting NFS server and services...
Sep 03 12:09:47 monolith systemd[1]: Started NFS server and services.

驗證 UID/GID 設定分別對應於nobodynogroup

$ id -u nobody
65534

$ getent group nogroup
nogroup:x:65534:

症狀

NFS 伺服器主機位於10.3.0.100。客戶端(OSX Sierra v10.12.6)位於10.3.0.102

我嘗試使用 finder 的“連接到伺服器”對話框 ( ) 進行連接cmd + k,我在其中輸入了nfs://10.3.0.100

這樣做會產生以下錯誤: You do not have permission to access this server

這是配置問題嗎?我做錯了什麼?

答案1

為了使用 MacOS 連接到 NFS 共享,必須使用不安全標誌定義共享。這意味著它允許從非標準連接埠(macOS 使用的)進行連接。所以你的匯出行看起來像這樣。

10.3.0.0/16 (rw,all_squash,sync,no_subtree_check,anonuid=65534,anongid=65534,insecure)

此外,從 Mac 連接時(尤其是在 nfsv3 上),您必須連接到特定的匯出資料夾,而不是根資料夾或僅連接 IP。

nfs://10.3.0.100/bottle/media

應該做的伎倆!

相關內容