SOLVED ifconfig tun0 difficulties with openvpn

ovalcoconut

Dabbler
Joined
Feb 11, 2018
Messages
12
Running 11.3-U1 newly updated from 11.2-U8 posted here first

Background
I had a running warden jail with transmission and openvpn (with PIA) for awhile on 11.1 using this guide then later I updated to 11.2 and I didn't bother migrating the jail from warden to iocage as it was still working.

I was having permissions issues in a separate (iocage) jail that I couldn't narrow down (Completely unrelated issue, solved now). I thought that updating the jail may fix it, it did not. I thought updating the host would solve it, it did not.
Upon updating to 11.3 I realize that warden had been removed completely, killing my working jail. -- "Oh well, I can just rebuild it in iocage now, good learning experience."

I read a bit of this guide in the transmission section to plan my moves.
The new guide doesn't have any notes on openvpn setup, so I fell back onto the old guide, which should do fine as it's pretty much just config files.

The Issue
I haven't even gotten to setting up the firewall as I can't get openvpn to start due to issues with creating/unhiding tun0

/var/log/messages:

Code:
    Mar 23 16:17:27 transmission openvpn[98848]: OpenVPN 2.4.8 amd64-portbld-freebsd11.3 [SSL (OpenSSL)] [LZO] [LZ4] [MH/RECVDA] [AEAD] built on Jan 31 2020
    Mar 23 16:17:27 transmission openvpn[98848]: library versions: OpenSSL 1.0.2o-freebsd  27 Mar 2018, LZO 2.10
    Mar 23 16:17:27 transmission openvpn[98849]: TCP/UDP: Preserving recently used remote address: [AF_INET]174.128.243.98:1198
    Mar 23 16:17:27 transmission openvpn[98849]: UDP link local: (not bound)
    Mar 23 16:17:27 transmission openvpn[98849]: UDP link remote: [AF_INET]174.128.243.98:1198
    Mar 23 16:17:27 transmission openvpn[98849]: WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
    Mar 23 16:17:27 transmission openvpn[98849]: [7a0de1d2acfc5854c5330e7aeb0c3fb8] Peer Connection Initiated with [AF_INET]174.128.243.98:1198
    Mar 23 16:17:28 transmission openvpn[98849]: TUN/TAP device /dev/tun0 opened
    Mar 23 16:17:28 transmission openvpn[98849]: /sbin/ifconfig tun0 10.36.11.6 10.36.11.5 mtu 1500 netmask 255.255.255.255 up
    Mar 23 16:17:28 transmission openvpn[98849]: FreeBSD ifconfig failed: external program exited with error status: 1
    Mar 23 16:17:28 transmission openvpn[98849]: Exiting due to fatal error
    Mar 23 16:52:41 transmission openvpn[3985]: OpenVPN 2.4.8 amd64-portbld-freebsd11.3 [SSL (OpenSSL)] [LZO] [LZ4] [MH/RECVDA] [AEAD] built on Jan 31 2020
    Mar 23 16:52:41 transmission openvpn[3985]: library versions: OpenSSL 1.0.2o-freebsd  27 Mar 2018, LZO 2.10
    Mar 23 16:52:41 transmission openvpn[3986]: TCP/UDP: Preserving recently used remote address: [AF_INET]174.128.245.106:1198
    Mar 23 16:52:41 transmission openvpn[3986]: UDP link local: (not bound)
    Mar 23 16:52:41 transmission openvpn[3986]: UDP link remote: [AF_INET]174.128.245.106:1198
    Mar 23 16:52:41 transmission openvpn[3986]: WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
    Mar 23 16:52:41 transmission openvpn[3986]: [67a92ac75cf9e2c6aced3b82e01bc951] Peer Connection Initiated with [AF_INET]174.128.245.106:1198
    Mar 23 16:52:43 transmission openvpn[3986]: TUN/TAP device /dev/tun0 opened
    Mar 23 16:52:43 transmission openvpn[3986]: /sbin/ifconfig tun0 10.72.10.6 10.72.10.5 mtu 1500 netmask 255.255.255.255 up
    Mar 23 16:52:43 transmission openvpn[3986]: FreeBSD ifconfig failed: external program exited with error status: 1
    Mar 23 16:52:43 transmission openvpn[3986]: Exiting due to fatal error

I tried just starting openvpn not as a service and I get this:
Code:
    Mon Mar 23 16:57:37 2020 OpenVPN 2.4.8 amd64-portbld-freebsd11.3 [SSL (OpenSSL)] [LZO] [LZ4] [MH/RECVDA] [AEAD] built on Jan 31 2020
    Mon Mar 23 16:57:37 2020 library versions: OpenSSL 1.0.2o-freebsd  27 Mar 2018, LZO 2.10
    Mon Mar 23 16:57:37 2020 TCP/UDP: Preserving recently used remote address: [AF_INET]174.128.243.106:1198
    Mon Mar 23 16:57:37 2020 UDP link local: (not bound)
    Mon Mar 23 16:57:37 2020 UDP link remote: [AF_INET]174.128.243.106:1198
    Mon Mar 23 16:57:37 2020 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
    Mon Mar 23 16:57:37 2020 [8c51f84393f1075e9e60f027aee3b712] Peer Connection Initiated with [AF_INET]174.128.243.106:1198
    Mon Mar 23 16:57:38 2020 TUN/TAP device /dev/tun0 opened
    Mon Mar 23 16:57:38 2020 /sbin/ifconfig tun0 10.41.10.10 10.41.10.9 mtu 1500 netmask 255.255.255.255 up
    ifconfig: interface tun0 does not exist
    Mon Mar 23 16:57:38 2020 FreeBSD ifconfig failed: external program exited with error status: 1
    Mon Mar 23 16:57:38 2020 Exiting due to fatal error

note the extra line: *ifconfig: interface tun0 does not exist*

which is accurate, here's ifconfig:
Code:
    root@transmission:~ # ifconfig
    lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
            options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
            inet6 ::1 prefixlen 128
            inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
            inet 127.0.0.1 netmask 0xff000000
            nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
            groups: lo
    epair0b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
            options=8<VLAN_MTU>
            ether 02:ff:60:03:aa:47
            hwaddr 02:80:d0:00:0b:0b
            inet 192.168.1.23 netmask 0xffffff00 broadcast 192.168.1.255
            nd6 options=1<PERFORMNUD>
            media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
            status: active
            groups: epair
    root@transmission:~ #

More recently in the guide I used back in 11.1 I found this thread where apparently using iocage set allow_tun=1 transmission would fix my problem...
but I'm not that fortunate:
Code:
    root@BlargNAS:~ # iocage set allow_tun=1 transmission
    allow_tun: 1 -> 1
    root@BlargNAS:~ #

It was already set when I built the jail.
iocage create -n "transmission" -p /tmp/pkg.json -r 11.2-RELEASE ip4_addr="vnet0|192.168.1.23/24" defaultrouter="192.168.1.1" vnet="on" allow_raw_sockets="1" boot="on" allow_tun="1"

But in the new guide there's that line devfs rule -s 4 add path 'tun*' unhide that should make tun devices available in my iocage jail right‽
Yes of course, but what if it's already applied?
Code:
    root@BlargNAS:~ # devfs rule -s 4 show
    100 include 1
    200 include 2
    300 include 3
    400 path zfs unhide
    500 path tun* unhide
    root@BlargNAS:~ #

oh.

"Well maybe I can just make one"
Code:
    root@transmission:~ # ifconfig tun0
    ifconfig: interface tun0 does not exist
    root@transmission:~ # ifconfig tun0 create
    ifconfig: SIOCIFCREATE2: File exists
    root@transmission:~ #

Well there's where I stand, tun0 is missing/hidden/shy and I'm stuck unable to run openvpn. I may try again from scratch in a day or two and see if I can get it working.

Anyone have any ideas? At the moment, all of mine are spent.
I'm assuming that I've missed a critical step somewhere, or perhaps my understanding of the problem is flawed. Another perspective would be appreciated.
 
Joined
Jan 4, 2014
Messages
1,644
In the transmission jail, if you type ifconfig, do you see any tun device?
 

ovalcoconut

Dabbler
Joined
Feb 11, 2018
Messages
12
I do not:
Code:
root@transmission:~ # ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
        groups: lo
epair0b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 02:ff:60:03:aa:47
        hwaddr 02:80:d0:00:0b:0b
        inet 192.168.1.23 netmask 0xffffff00 broadcast 192.168.1.255
        nd6 options=1<PERFORMNUD>
        media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
        status: active
        groups: epair
root@transmission:~ #
 
Joined
Jan 4, 2014
Messages
1,644
You do have the devfs rule as a pre-init task and have rebooted the server prior to configuring the transmission jail?
 

ovalcoconut

Dabbler
Joined
Feb 11, 2018
Messages
12
Setup like this right?
1585022082839.png


I didn't reboot the host before creating the jail, but is has been rebooted several times since.
Though I did run devfs rule -s 4 path 'tun*' unhide before creating it, just minus the reboot.

Would you suggests I start with a new jail after a reboot?
 
Joined
Jan 4, 2014
Messages
1,644
Stripping it back, I created a test jail with just OpenVPN and after configuring and starting it confirmed that ifconfig shows a tun device.
 
Last edited:

ovalcoconut

Dabbler
Joined
Feb 11, 2018
Messages
12
Hmm... I'm not sure what I'm missing. I try a new jail then and see what I get.
 

ovalcoconut

Dabbler
Joined
Feb 11, 2018
Messages
12
Alright, so I got it working.

The solution was to just create a tun device manually using ifconfig tun create.
Code:
root@transmission:~ # ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
        groups: lo
epair0b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 02:ff:60:03:aa:47
        hwaddr 02:80:d0:00:0b:0b
        inet 192.168.1.23 netmask 0xffffff00 broadcast 192.168.1.255
        nd6 options=1<PERFORMNUD>
        media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
        status: active
        groups: epair
tun1: flags=8010<POINTOPOINT,MULTICAST> metric 0 mtu 1500
        options=80000<LINKSTATE>
        nd6 options=1<PERFORMNUD>
        groups: tun
root@transmission:~ #

For some reason the tun device did not auto-create with the creation of the jail and my initial attempt at creation using ifconfig tun0 create didn't work.

A big thanks to this thread: https://www.ixsystems.com/community/threads/openvpn-tun-interface-issues-in-iocage.68953/ for containing the answer.

A weird problem, and there may be an underlying issue somewhere else that's the cause of this, but right now I'm just happy that I got it working.
 
Top