我的 nfs 服务器在192.168.1.99
box 上运行,并且我使用以下命令配置了 /etc/exports
/myshare 192.168.1.*(rw,sync,no_subtree_check)
我能够从192.168.1.50
客户端机箱挂载 nfs。
但是我无法挂载192.168.1.49
!(“mount.nfs mount(2) 权限被拒绝”,后跟“挂载时服务器拒绝 mount.nfs 访问”)
然后我发现如果我将客户端的IP改为192.168.1.48
192.168.1.0/24
最后,我可以使用192.168.1.*
有人能解释一下为什么192.168.1.0/24
对 有效192.168.1.49
,但192.168.1.*
对 无效吗?
netmask 255.255.255.0
network 192.168.1.0
... 我不是管理员,而且对子网的理解也不够... Ubuntu64,12.04...
答案1
请参阅的手册页exports(5)
:
Machine Name Formats
NFS clients may be specified in a number of ways:
[...]
IP networks
You can also export directories to all hosts on an IP (sub-) network
simultaneously. This is done by specifying an IP address and netmask pair
as address/netmask where the netmask can be specified in dotted-decimal
format, or as a contiguous mask length. For example, either
`/255.255.252.0' or `/22' appended to the network base IPv4 address
results in identical subnetworks with 10 bits of host. [...]
Wildcard characters generally do not work on IP addresses, though they
may work by accident when reverse DNS lookups fail.
wildcards
Machine names may contain the wildcard characters * and ?, or may contain
character class lists within [square brackets]. This can be used to make
the exports file more compact; for instance, *.cs.foo.edu matches all
hosts in the domain cs.foo.edu. As these characters also match the dots
in a domain name, the given pattern will also match all hosts within any
subdomain of cs.foo.edu.
这仅仅意味着你配置错误
/myshare 192.168.1.*(rw,sync,no_subtree_check)
通配符可用于主机名,为了指定 IP 网络,您需要使用点分十进制 IP 地址和可选子网大小。上面的反向 IP 查找故事可以解释为什么它适用于特定地址。