如何指定挂载nfs时使用的ipv6地址

我的笔记本电脑有几个IPv6地址。 我的NAS只接受一个特定的这些用NFS挂载NAS文件夹。

我装上NAS的份额

sudo mount [fd80:foo::bar]:/Media /mnt/NASshare

但是,有了这个机会,我的笔记本电脑使用其中一个IPv6地址,这是NAS不允许的。

我的问题是:如何在安装NAS共享时指定IPv6地址?

从NFS(5)nfs – fstab格式和nfs文件系统选项:

  clientaddr=nnnn 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. 

这将build议将其添加到/etc/fstab (使用fd80:c0f::fee作为所需的IP地址):

 fd80:foo::bar:/Media /mnt/NASshare nfs rw,clientaddr=fd80:c0f::fee 0 0 

但是如前所述,这个自动发现过程并不完美。

这可能是你需要添加特定的route到你的NAS。

或者如果可以使用ip netns命名空间,那么你可以:

  1. 创build一个名称空间: ip netns add NASNamespace
  2. 链接到接口: ip link set eth0 netns NASNamespace
  3. 为它configuration一个IP: ip netns exec NASNamespace ifconfig eth0 fd80:c0f::fee/64 up
  4. 强制挂载在命名空间内运行: ip netns exec NASNamespace mount