
私はIPアドレスが のUbuntu 16.04ホスト192.168.1.35
と、2つのVMクライアント(Debian 8 JessieとCentOS 7)を持っています。私はnfs server
ホストとnfs client
ゲストの両方で実行しています。Debianゲストでは問題なくホストからマウントできますnfs-share
。問題は私のCentOSゲストにあります。
ゲスト内から nfs 共有をマウントしようとすると、次のエラーが発生します。
[hedin@localhost ~]$ sudo mount -a
mount.nfs: access denied by server while mounting 192.168.1.35:/home/hedin/export/eudyptula
これはゲストの /etc/fstab です:
#
# /etc/fstab
# Created by anaconda on Mon Apr 10 16:16:12 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0 0
UUID=46ddae58-4556-492c-8e23-8c56a4e067d9 /boot xfs defaults 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
192.168.1.35:/home/hedin/export/eudyptula /home/hedin/mnt/host nfs rw,hard,intr,bg 0 0
ファイアウォールが無効になっています:
[hedin@localhost ~]$ systemctl is-enabled firewalld
disabled
SELinux が無効になっています:
[hedin@localhost ~]$ cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
SELINUX=disabled
SELINUXTYPE=targeted
すべてのホストが許可されます:
[hedin@localhost ~]$ cat /etc/hosts.allow
#
# hosts.allow This file contains access rules which are used to
ALL: ALL: ALLOW
ゲスト内からホストの nfs-share を確認できます。
[hedin@localhost ~]$ sudo showmount -e 192.168.1.35
Export list for 192.168.1.35:
/home/hedin/export/eudyptula 192.168.1.0/24
/home/hedin/export 192.168.1.0/24
これが私のホストの/etc/export
設定です:
hedin@home:~/projects/open-source/linux$ cat /etc/exports
/home/hedin/export 192.168.1.0/24(rw,fsid=0,insecure,no_subtree_check,async)
/home/hedin/export/eudyptula 192.168.1.0/24(rw,nohide,insecure,no_subtree_check,async)
つまり、設定で何を見逃したのか分かりません。何かアイデアはありますか?
答え1
問題はサーバーの /etc/exports ファイルにありました。クライアントの VM IP がサーバーの IP マスクと一致しませんでした。任意の IP へのアクセスを許可し、ゲストに共有をマウントできるようになりました。新しい構成は次のとおりです。
/home/hedin/export *(rw,fsid=0,insecure,no_subtree_check,async)
/home/hedin/export/eudyptula *(rw,nohide,insecure,no_subtree_check,async)
答え2
/etc/sysconfig/selinux ファイル内の次の行を削除し、centos 7 マシンを再起動してください。
SELINUXTYPE=ターゲット
/etc/fstab ファイル内の次の行を更新し、CentOS 7 マシンで共有フォルダーを再度マウントしてください。
192.168.1.35:/home/hedin/export/eudyptula /home/hedin/mnt/host nfs デフォルト 0 0