In case you can't connect OpenVPN in Alpine Linux due to '/dev/net/tun not found'
Quick posting for a quick fix regarding Alpine: earlier today I wasn't able to reach my VPN servers with it via the openvpn
command-line tool. The message indicated that the device file /dev/net/tun
was not found in the system, to which I initially attributed to an unattended kernel upgrade (I had ran apk upgrade
in the same session previously and noticed that the kernel was also in the line to be upgraded).
When a reboot didn't fix it, I started to wonder what could be happening and went out to search for a possible fix. The results pointed me to this SO page which, despite sounding like quite an ugly hack, managed to fix the whole thing seamlessly to me. Here's the TL;DR:
First off, yes, the file is indeed missing, so you can't create the VPN tunnel. However, you can create one on behalf of a process! To do so correctly, these are the commands:
# as root, of course.
mkdir -p /dev/net
mknod /dev/net/tun c 10 200
chmod 600 /dev/net/tun
And bingo, just run openvpn yourconfig.ovpn
and watch the connection go through, just as intended. The rest of the answer concerns making the commands above into a cron job script so that every reboot the file is recreated, but that's enough for me as it is.
Wonder what happened in first place so that OpenVPN doesn't create the file by itself. But oh well, this one seems good enough to me!