
我有 IP 位址為 的 Ubuntu 16.04 主機192.168.1.35
,以及兩個 VM 用戶端:Ddebian 8 Jessie 和 CentOS 7 nfs server
。nfs client
從 Debian guest 開始,它可以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 檔案。客戶端的虛擬機器 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