Ubuntu – NFS fails to mount through openvpn tunnel

debianmountnfsopenvpnUbuntu

I am trying to establish an nfs connection through an openvpn tunnel.
It really anoying and i dont know what to try next. The connectein test has
been made on several platforms now. used debian/centos/openwrt.
Changed server<>client

A "direct" nfs connection alway works instant by doing: (DEMO IP HERE)

mount -t nfs 192.168.2.1:/extroot test

but an:

mount -t nfs 10.0.0.1:/extroot test

always fails with: (takes forever to timeout)

mount.nfs: Connection timed out

Also i did that on a remote vps and the connection is established instant.
The openvpn tunnel seems fine. Ping ok iperf greather 100mbits soo …..

My configs atached, any help is verry welcome!

NFS:

/etc/exports: ( '*' is just for debugging here )

/extroot *(rw,all_squash,insecure,async,no_subtree_check)

/etc/hosts.allow

portmap: ALL

openvpn:

server.conf:

port 6565
proto udp
dev tun
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key
dh /etc/openvpn/keys/dh2048.pem
server 10.0.0.0 255.255.255.0
ifconfig-pool-persist /etc/openvpn/ipp.txt
keepalive 5 30
verb 3

client.conf:

client
tls-client
dev tun
proto udp
remote hostname.of.server portnum
resolv-retry infinite
nobind
pkcs12 /etc/openvpn/nfs.p12
verb 3
remote-cert-tls server

tcpdump from nfs server while trying to connect:
http://pastebin.com/2PJ2w7vB

i know its hard ti read, sorry.

Best Answer

Ok i got it. @Zoredache pointed me into the right direction. Thank you my friend :) !! Its indeed the case that mount.nfs is trying to point to localhost instead of the vpn ip. You can solve this by using the following mountopts.

/sbin/mount.nfs -v 10.0.0.1:/$remotepath /$localpath -o addr=10.0.0.1,clientaddr=10.0.0.6

Debug Output of mount.nfs

mount.nfs: timeout set for Sat Nov  1 08:49:42 2014
mount.nfs: trying text-based options 'clientaddr=10.0.0.6,vers=4,addr=10.0.0.1'

If You want to solve this inside initramfs, you need to add /sbin/mount.nfs to your initramfs. The generic command mounting nfs during boot for nfsroot will fail otherwise.