我的笔记本电脑有几个 IPv6 地址。我的 NAS 只接受其中一个特定的来使用 NFS 挂载 NAS 文件夹。
我挂载了 NAS 共享
sudo mount [fd80:foo::bar]:/Media /mnt/NASshare
但是这样一来,我的笔记本电脑使用其中一个 IPv6 地址的可能性很高,而 NAS 不允许这样做。
我的问题是:如何在安装 NAS 共享时指定 IPv6 地址?
来自 NFS(5) nfs - nfs 文件系统的 fstab 格式和选项:
clientaddr=n.n.n.n
clientaddr=n:n:...:n
Specifies a single IPv4 address (in dotted-quad form),
or a non-link-local IPv6 address, that the NFS client
advertises to allow servers to perform NFS version 4
callback requests against files on this mount point. If
the server is unable to establish callback connections
to clients, performance may degrade, or accesses to
files may temporarily hang.
If this option is not specified, the mount(8) command
attempts to discover an appropriate callback address
automatically. The automatic discovery process is not
perfect, however. In the presence of multiple client
network interfaces, special routing policies, or atypi-
cal network topologies, the exact address to use for
callbacks may be nontrivial to determine.
Run Code Online (Sandbox Code Playgroud)
这会建议将此添加到/etc/fstab
(使用fd80:c0f::fee
所需的 IP 地址):
fd80:foo::bar:/Media /mnt/NASshare nfs rw,clientaddr=fd80:c0f::fee 0 0
Run Code Online (Sandbox Code Playgroud)
但如前所述,这种自动发现过程并不完美。
可能是您需要添加特定route
于您的 NAS。
或者,如果可以使用ip netns
命名空间,那么您可以:
ip netns add NASNamespace
.ip link set eth0 netns NASNamespace
ip netns exec NASNamespace ifconfig eth0 fd80:c0f::fee/64 up
ip netns exec NASNamespace mount