Mount WAN NFS in OPNsense LAN

Mounting a NFS in WAN may fail. See this article for a quick solution.

Mount WAN NFS in OPNsense LAN
Photo by Taylor Vick / Unsplash

Mounting a NFS in the WAN fails, if the client is in the OPNsense LAN. In this setup WAN is 192.168.178.0 while LAN is 10.2.82.0. The error message on mounting the share is:

$ mount -v storage.wan:/ /mnt/nfs
mount.nfs: timeout set for Fri Feb 10 10:19:28 2023
mount.nfs: trying text-based options 'vers=4.2,addr=192.168.178.47,clientaddr=10.2.82.100'
mount.nfs: mount(2): Operation not permitted
mount.nfs: trying text-based options 'addr=192.168.178.47'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 192.168.178.47 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 192.168.178.47 prog 100005 vers 3 prot UDP port 47467
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting storage.wan:/

A quick solution is to add the insecure flag to the exports on the server:

# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
/mnt/storage        192.168.178.0/255.255.255.0(rw,async,fsid=0,no_subtree_check,insecure)

After applying the change through exportfs -arv , mounting is successful:

$ mount -v storage.wan:/ /mnt/nfs
mount.nfs: timeout set for Fri Feb 10 10:22:29 2023
mount.nfs: trying text-based options 'vers=4.2,addr=192.168.178.47,clientaddr=10.2.82.100'