Skip to content

Instantly share code, notes, and snippets.

@MartinBrugnara
Created March 27, 2021 18:00
Show Gist options
  • Save MartinBrugnara/fab3831e34e6703884bcf29126dcfc53 to your computer and use it in GitHub Desktop.
Save MartinBrugnara/fab3831e34e6703884bcf29126dcfc53 to your computer and use it in GitHub Desktop.
NFS 4 uses wrong clientaddr
TL;DR; Force the use nfs4.0 (the issue arises with nfs > 4.1).
# Situation:
* NFS server with multiple IP. E.g. different subnets for different access levels and or bandwidth/MTU.
IPs
192.168.10.1
192.168.20.1
Exports:
/srv/nfs/lvl10 192.168.10.0/255.255.255.0
/srv/nfs/lvl20 192.168.20.0/255.255.255.0
* Client with one IP per network wants to mount everything.
IPs
192.168.10.2
192.168.20.2
/etc/fstab
nas_10:srv/nfs/lvl10 /mnt/lvl10 nfs vers=4,timeo=14,intr,_netdev 0 0
nas_20:srv/nfs/lvl20 /mnt/lvl20 nfs vers=4,timeo=14,intr,_netdev 0 0
# Issue:
mount.nfs: mounting nas_20:srv/nfs/lvl20 failed, reason given by server: No such file or directory
# Cause:
The client is using the wrong IP to exchange data with the NFS server.
How to verify ->
Mount the nfs_20 nfs root on the client and then see the details of the connection
$ mkdir tmp && mount -t nfs nas_20:/ tmp
$ mount | grep nas_20
The output should be something like:
nas_20:/srv/nfs/ on /home/martin/tmp type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=14,retrans=2,sec=sys,clientaddr=192.168.10.2,local_lock=none,addr=192.168.10.1)
Notice how the *.10.2 address is used to exchange data with nas_20, which is on 20.1 ,
thus only folders exported in *.10.0/24 will be visible.
# Solution:
Force the usage of nfs4.0
Tested on Fedora 32 beta.
# P.S
Setting `addr` or `clientaddr` does nothing with 4.1, 4.2.
---
Likley underlining cause:
From `man nfs`:
> clientaddr=n:n:...:n
> ...
> NFS protocol versions 4.1 and 4.2 use the client-established TCP connection for callback requests, so do
> not require the server to connect to the client. This option is therefore only affect NFS version 4.0
> mounts.
---
Possibly same/related issue by someone on Proxmos:
https://forum.proxmox.com/threads/nfs-mounts-using-wrong-source-ip-interface.70754/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment