{{ figure caption=“Photo by Steven Wright on Unsplash” >}}
If you’re looking into running OpenVPN on your Synology NAS, you may have come across the following error:
ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Let’s see how to fix it.
Check the tun module status#
Check if you have the tun module installed:
❯ lsmod | grep tun
If the result comes out empty, try installing it:
❯ insmod /lib/modules/tun.ko
If everything went fine, move on to the next test.
Test if the tun.ko module works#
Now let’s make sure the tun.ko module works as expected:
❯ mkdir /dev/net
❯ mknod /dev/net/tun c 10 200
❯ chmod 600 /dev/net/tun
❯ cat /dev/net/tun
If the result of the cat command was File descriptor in bad state, it means the module has been correctly installed.
Make tun.ko module persistent#
The module installation needs to be made persistent otherwise on every Synology restart, you’ll have to repeat the insmod command.
Create the following file to run on every system boot:
❯ cat <<EOF > /usr/local/etc/rc.d/tun.sh
#!/bin/sh -e
insmod /lib/modules/tun.ko
EOF
Make the script executable:
❯ chmod a+x /usr/local/etc/rc.d/tun.sh
Reboot your Synology NAS or execute the script manually once. Done!
