OpenWrt Forum Archive

Topic: OpenVPN connection with my openwrt router

The content of this topic has been archived on 19 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hey guys,

am trying to make an openvpn server of my router, so i can connect from the outside/inside with my local lan to do some maintance on my  pi.

I installed opkg install openvpn-openssl openvpn-easy-rsa and followed the post on:
wiki.openwrt.org/doc/howto/vpn.openvpn

I opened the ports on my ISP modem/router and forwarded it to my openwrt router.
but the connection wont come up, the openvpn log says: MANAGEMENT: >STATE:1503950087,WAIT,,,,,,

Here is my output of the commands:
cat /tmp/openvpn.log
cat /etc/config/network
cat /etc/config/firewall
cat /etc/config/openvpn

root@Unknown:~# cat /tmp/openvpn.log
cat: can't open '/tmp/openvpn.log': No such file or directory
root@Unknown:~# cat /etc/config/network

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'XX.XX.XX.XX::/48'

config interface 'lan'
        option ifname 'eth1'
        option force_link '1'
        option type 'bridge'
        option proto 'static'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option ipaddr '192.168.1.254'
        option dns 'XX.XX.XX.22 XX.XX.XX.23 8.8.8.8 8.8.4.4'

config interface 'wan'
        option ifname 'eth0'
        option _orig_ifname 'eth0'
        option _orig_bridge 'false'
        option proto 'static'
        option ipaddr '192.168.178.11'
        option netmask '255.255.255.0'
        option gateway '192.168.178.1'
        option delegate '0'
        option type 'bridge'
        option dns '.XX.XX.XX.22 XX.XX.XX.23'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '0 2 3 4 5'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '1 6'

config route
        option interface 'lan'
        option target '0.0.0.0'
        option gateway '192.168.178.1'

config route

config interface 'vpn0'
        option ifname 'tun0'
        option proto 'none'
        option auto '1'

root@Unknown:~# cat /etc/config/firewall

config defaults
        option syn_flood '1'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'REJECT'

config zone
        option name 'lan'
        list network 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'

config zone
        option name 'wan'
        list network 'wan'
        list network 'wan6'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option masq '1'
        option mtu_fix '1'

config forwarding
        option src 'lan'
        option dest 'wan'

config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'

config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option src_ip 'fe80::/10'
        option src_port '547'
        option dest_ip 'fe80::/10'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config include
        option path '/etc/firewall.user'

config include 'miniupnpd'
        option type 'script'
        option path '/usr/share/miniupnpd/firewall.include'
        option family 'any'
        option reload '1'

config include 'bcp38'
        option type 'script'
        option path '/usr/lib/bcp38/run.sh'
        option family 'IPv4'
        option reload '1'

config redirect
        option target 'DNAT'
        option src 'wan'
        option dest 'lan'
        option proto 'tcp'
        option src_dport '80'
        option dest_ip '192.168.1.104'
        option dest_port '80'
        option name 'Apache Server to Pi'
        option enabled '0'

config redirect
        option target 'DNAT'
        option src 'wan'
        option dest 'lan'
        option proto 'tcp udp'
        option src_dport '8080'
        option dest_ip '192.168.1.104'
        option dest_port '8080'
        option name 'Apache Server to Pi'
        option enabled '0'

config rule 'Allow_OpenVPN_Inbound'
        option target 'ACCEPT'
        option src '*'
        option proto 'udp'
        option dest_port '1194'

config zone 'vpn'
        option name 'vpn'
        option network 'vpn0'
        option input 'ACCEPT'
        option forward 'REJECT'
        option output 'ACCEPT'
        option masq '1'

config forwarding 'vpn_forwarding_lan_in'
        option src 'vpn'
        option dest 'lan'

config forwarding 'vpn_forwarding_lan_out'
        option src 'lan'
        option dest 'vpn'

config forwarding 'vpn_forwarding_wan'
        option src 'vpn'
        option dest 'wan'

config redirect
        option enabled '1'
        option target 'DNAT'
        option src 'wan'
        option dest 'vpn'
        option proto 'udp'
        option src_dport '1194'
        option dest_ip '192.168.1.254'
        option dest_port '1194'
        option name 'VPN'

root@Unknown:~# cat /etc/config/openvpn

config openvpn 'lan'
        option enable '1'
        option port '1194'
        option proto 'udp'
        option dev 'tun'
        option ca '/etc/easy-rsa/keys/ca.crt'
        option cert '/etc/easy-rsa/keys/server.crt'
        option key '/etc/easy-rsa/keys/server.key'
        option dh '/etc/easy-rsa/keys/dh2048.pem'
        option ifconfig_pool_persist '/tmp/ipp.txt'
        option keepalive '10 120'
        option comp_lzo 'no'
        option persist_key '1'
        option persist_tun '1'
        option status '/var/log/openvpn-status.log'
        option verb '3'
        option server '10.0.0.0 255.255.255.0'
        option client_to_client '1'
        list push 'redirect-gateway def1'
        list push 'dhcp-option DNS 192.168.1.254'
        list push 'route 192.168.1.0 255.255.255.0'
        option enabled '1'

Could someone please help with a push in the right direction. Maybe it is something noobish what am asking, just let me know wink

Thanks in regards!

Hpower

What is it?

config redirect
        option enabled '1'
        option target 'DNAT'
        option src 'wan'
        option dest 'vpn'
        option proto 'udp'
        option src_dport '1194'
        option dest_ip '192.168.1.254'
        option dest_port '1194'
        option name 'VPN'

Do you see in vpn-logs of server anything?

config redirect
        option enabled '1'
        option target 'DNAT'
        option src 'wan'
        option dest 'vpn'
        option proto 'udp'
        option src_dport '1194'
        option dest_ip '192.168.1.254'
        option dest_port '1194'
        option name 'VPN'

Do not do this; remove this section entirely.  The "Allow_OpenVPN_Inbound" rule from the wiki recipe is sufficient to get VPN requests from the WAN to port 1194 in your router.
Using src '*' makes sure you could log in to the VPN server from your LAN, useful for testing.  It could be src 'wan'.

(Last edited by mk24 on 29 Aug 2017, 21:35)

Thanks for the response!!
I removed the section mk24 metioned and change src '*' into src 'wan'.

My openvpn logfile is empty:

-rwx--x--x    1 root     root             0 Aug 31 20:45 openvpn-status.log

I can connect to my openvpn server cause it is my router?

i can do a /etc/init.d/openvpn start without an error but still it seems not let any vpn connections in.

when i do a nmap scan local:
sudo nmap -Pn -sU -p 1194 192.168.1.254

Starting Nmap
Nmap scan report for Unknown.lan (192.168.1.254)
Host is up (0.00024s latency).

PORT     STATE  SERVICE
1194/udp closed openvpn

nmap on my public ip:

Starting Nmap
Nmap scan report for XX.XX.XX.XX
Host is up.

PORT     STATE         SERVICE
1194/udp open|filtered openvpn

Is there any other method to see if my openvpn server is active on my router?

Empty log means you have troubles with starting openvpn-server. Add more verbosity 'verb 5', do you see it in processes?

ps | grep openvpn

Kill it and start manually from console:

/etc/init.d/openvpn stop
/etc/init.d/openvpn start

What do you see in log and in console?

You have typo in your openvpn config:
Your option:

option enable '1'

Correct option:

option enabled '1'

(Last edited by ulmwind on 31 Aug 2017, 20:21)

I edit the verb and change enable to enabled but still nothing in the log file.
I think it has problems with starting the openvpn...


the

ps | grep openvpn

command gives:

7321 root      1364 S    grep openvpn

Gonna try to reinstall it tomorrow will update this post.
Thanks for the help so far!

Try looking at the regular logread.

Then /etc/init.d/openvpn restart and check the log again.

Change

config openvpn 'lan'

for something like

config openvpn 'myvpn'

Yes, restart openvpn and see log

logread -e openvpn

Ok did what you asked, got some nice information now, where i further can work on.
Will do some internet research thanks!

Fri Sep  1 19:39:11 2017 daemon.warn openvpn(openvpn)[7500]: Warning: Error redi                                                                                        recting stdout/stderr to --log file: /var/log/openvpn/openvpn.log: No such file                                                                                         or directory (errno=2)
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(myvpn)[7499]: OpenVPN 2.3.6 mips-                                                                                        openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 2016
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(myvpn)[7499]: library versions: O                                                                                        penSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(openvpn)[7500]: OpenVPN 2.3.6 mip                                                                                        s-openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 20                                                                                        16
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(openvpn)[7500]: library versions:                                                                                         OpenSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(openvpn)[7500]: Diffie-Hellman in                                                                                        itialized with 2048 bit key
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(myvpn)[7499]: Diffie-Hellman init                                                                                        ialized with 2048 bit key
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(myvpn)[7499]: TLS-Auth MTU parms                                                                                         [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(myvpn)[7499]: Socket Buffers: R=[                                                                                        163840->131072] S=[163840->131072]
Fri Sep  1 19:39:11 2017 daemon.err openvpn(myvpn)[7499]: ERROR: Cannot open TUN                                                                                        /TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(myvpn)[7499]: Exiting due to fata                                                                                        l error
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(openvpn)[7500]: TLS-Auth MTU parm                                                                                        s [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(openvpn)[7500]: Socket Buffers: R                                                                                        =[163840->131072] S=[163840->131072]
Fri Sep  1 19:39:11 2017 daemon.err openvpn(openvpn)[7500]: ERROR: Cannot open T                                                                                        UN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:39:11 2017 daemon.notice openvpn(openvpn)[7500]: Exiting due to fa                                                                                        tal error
Fri Sep  1 19:39:16 2017 daemon.warn openvpn(openvpn)[7504]: Warning: Error redi                                                                                        recting stdout/stderr to --log file: /var/log/openvpn/openvpn.log: No such file                                                                                         or directory (errno=2)
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(openvpn)[7504]: OpenVPN 2.3.6 mip                                                                                        s-openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 20                                                                                        16
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(openvpn)[7504]: library versions:                                                                                         OpenSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(openvpn)[7504]: Diffie-Hellman in                                                                                        itialized with 2048 bit key
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(openvpn)[7504]: TLS-Auth MTU parm                                                                                        s [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(openvpn)[7504]: Socket Buffers: R                                                                                        =[163840->131072] S=[163840->131072]
Fri Sep  1 19:39:16 2017 daemon.err openvpn(openvpn)[7504]: ERROR: Cannot open T                                                                                        UN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(openvpn)[7504]: Exiting due to fa                                                                                        tal error
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(myvpn)[7503]: OpenVPN 2.3.6 mips-                                                                                        openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 2016
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(myvpn)[7503]: library versions: O                                                                                        penSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(myvpn)[7503]: Diffie-Hellman init                                                                                        ialized with 2048 bit key
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(myvpn)[7503]: TLS-Auth MTU parms                                                                                         [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(myvpn)[7503]: Socket Buffers: R=[                                                                                        163840->131072] S=[163840->131072]
Fri Sep  1 19:39:16 2017 daemon.err openvpn(myvpn)[7503]: ERROR: Cannot open TUN                                                                                        /TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:39:16 2017 daemon.notice openvpn(myvpn)[7503]: Exiting due to fata                                                                                        l error
Fri Sep  1 19:39:21 2017 daemon.warn openvpn(openvpn)[7505]: Warning: Error redi                                                                                        recting stdout/stderr to --log file: /var/log/openvpn/openvpn.log: No such file                                                                                         or directory (errno=2)
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(openvpn)[7505]: OpenVPN 2.3.6 mip                                                                                        s-openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 20                                                                                        16
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(openvpn)[7505]: library versions:                                                                                         OpenSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(openvpn)[7505]: Diffie-Hellman in                                                                                        itialized with 2048 bit key
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(openvpn)[7505]: TLS-Auth MTU parm                                                                                        s [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(openvpn)[7505]: Socket Buffers: R                                                                                        =[163840->131072] S=[163840->131072]
Fri Sep  1 19:39:21 2017 daemon.err openvpn(openvpn)[7505]: ERROR: Cannot open T                                                                                        UN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(openvpn)[7505]: Exiting due to fa                                                                                        tal error
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(myvpn)[7507]: OpenVPN 2.3.6 mips-                                                                                        openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 2016
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(myvpn)[7507]: library versions: O                                                                                        penSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(myvpn)[7507]: Diffie-Hellman init                                                                                        ialized with 2048 bit key
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(myvpn)[7507]: TLS-Auth MTU parms                                                                                         [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(myvpn)[7507]: Socket Buffers: R=[                                                                                        163840->131072] S=[163840->131072]
Fri Sep  1 19:39:21 2017 daemon.err openvpn(myvpn)[7507]: ERROR: Cannot open TUN                                                                                        /TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:39:21 2017 daemon.notice openvpn(myvpn)[7507]: Exiting due to fata                                                                                        l error

okay, fixed the /var/log/openvpn error
created the folder and added more privileges.
Now i get a openvpn log:

Fri Sep  1 19:47:08 2017 us=809935 OpenVPN 2.3.6 mips-openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 2016
Fri Sep  1 19:47:08 2017 us=810139 library versions: OpenSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:47:08 2017 us=832959 Diffie-Hellman initialized with 2048 bit key
Fri Sep  1 19:47:08 2017 us=836721 TLS-Auth MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:47:08 2017 us=836926 Socket Buffers: R=[163840->131072] S=[163840->131072]
Fri Sep  1 19:47:08 2017 us=837789 ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:47:08 2017 us=837893 Exiting due to fatal error
Fri Sep  1 19:47:13 2017 us=849876 OpenVPN 2.3.6 mips-openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 2016
Fri Sep  1 19:47:13 2017 us=850066 library versions: OpenSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:47:13 2017 us=852812 Diffie-Hellman initialized with 2048 bit key
Fri Sep  1 19:47:13 2017 us=856664 TLS-Auth MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:47:13 2017 us=856868 Socket Buffers: R=[163840->131072] S=[163840->131072]
Fri Sep  1 19:47:13 2017 us=857747 ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:47:13 2017 us=857851 Exiting due to fatal error
Fri Sep  1 19:47:18 2017 us=871195 OpenVPN 2.3.6 mips-openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 2016
Fri Sep  1 19:47:18 2017 us=871387 library versions: OpenSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:47:18 2017 us=874084 Diffie-Hellman initialized with 2048 bit key
Fri Sep  1 19:47:18 2017 us=877754 TLS-Auth MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:47:18 2017 us=877962 Socket Buffers: R=[163840->131072] S=[163840->131072]
Fri Sep  1 19:47:18 2017 us=879513 ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:47:18 2017 us=879626 Exiting due to fatal error
Fri Sep  1 19:47:23 2017 us=902930 OpenVPN 2.3.6 mips-openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 2016
Fri Sep  1 19:47:23 2017 us=903118 library versions: OpenSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:47:23 2017 us=905797 Diffie-Hellman initialized with 2048 bit key
Fri Sep  1 19:47:23 2017 us=909521 TLS-Auth MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:47:23 2017 us=909728 Socket Buffers: R=[163840->131072] S=[163840->131072]
Fri Sep  1 19:47:23 2017 us=920751 ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:47:23 2017 us=920892 Exiting due to fatal error
Fri Sep  1 19:47:28 2017 us=933910 OpenVPN 2.3.6 mips-openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 2016
Fri Sep  1 19:47:28 2017 us=934097 library versions: OpenSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:47:28 2017 us=936805 Diffie-Hellman initialized with 2048 bit key
Fri Sep  1 19:47:28 2017 us=950676 TLS-Auth MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:47:28 2017 us=950932 Socket Buffers: R=[163840->131072] S=[163840->131072]
Fri Sep  1 19:47:28 2017 us=951948 ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:47:28 2017 us=952072 Exiting due to fatal error
Fri Sep  1 19:47:33 2017 us=965026 OpenVPN 2.3.6 mips-openwrt-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jan 31 2016
Fri Sep  1 19:47:33 2017 us=965217 library versions: OpenSSL 1.0.2j  26 Sep 2016, LZO 2.08
Fri Sep  1 19:47:33 2017 us=967903 Diffie-Hellman initialized with 2048 bit key
Fri Sep  1 19:47:33 2017 us=981727 TLS-Auth MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Sep  1 19:47:33 2017 us=981960 Socket Buffers: R=[163840->131072] S=[163840->131072]
Fri Sep  1 19:47:33 2017 us=982937 ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Fri Sep  1 19:47:33 2017 us=983063 Exiting due to fatal error

gonna search how to create a TUN file.

ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)

It is strange, that it tries to use device tun, it should use device tun0.
Start with changing

        option dev 'tun'

by

        option dev 'tun0'

Can you see device tun0 in output of

ifconfig

?

(Last edited by ulmwind on 1 Sep 2017, 19:08)

So all my changes of /etc/config/openvpn

config openvpn 'myvpn'
        option enabled '1'
        option port '1194'
        option proto 'udp'
        option dev 'tun0'
        option ca '/etc/easy-rsa/keys/ca.crt'
        option cert '/etc/easy-rsa/keys/server.crt'
        option key '/etc/easy-rsa/keys/server.key'
        option dh '/etc/easy-rsa/keys/dh2048.pem'
        option ifconfig_pool_persist '/tmp/ipp.txt'
        option keepalive '10 120'
        option comp_lzo 'no'
        option persist_key '1'
        option persist_tun '1'
        option status '/var/log/openvpn-status.log'
        option verb '5'
        option server '10.0.0.0 255.255.255.0'
        option client_to_client '1'
        list push 'redirect-gateway def1'
        list push 'dhcp-option DNS 192.168.1.254'
        list push 'route 192.168.1.0 255.255.255.0'
        option enabled '1'

no tun0 in my ifconfig..

and after a reboot the folder: /var/log/openvpn is gone.
i read that i need the permissions of the ./var folder cause it is read only?

/var is a link to /tmp, which is a RAM disk.  It will all be erased on reboot.

Okay thanks, changed the directory to /etc/openvpn in server.conf, at least it will create a log file smile

Okay after some more research the problem is with kmod-tun package...
i deleted the package and tried to reinstall, i get the error:

opkg install kmod-tun
Installing kmod-tun (3.18.23-1) to root...
Downloading http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/base/kmod-tun_3.18.23-1_ar71xx.ipk.
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-tun:
 *      kernel (= 3.18.23-1-b2f200610f46d20ef52d269421369d0c) *
 * opkg_install_cmd: Cannot install package kmod-tun.

it seems the package has the wrong kernel sad

Finally i got it working!! smile

I installed LEDE on my router cause of the problem with virtual tun creation..

After that i had some problems starting openvpn and my certificates where gone.
Reinstalled Openvpn and rebuild my certificates on my laptop.
Had some problem with the client.crt cause of the index.txt wasn't empty (delete the content with admin privileges).

I could make a vpn connection but couldn't get connected to anything else.
searching in the log i saw that the comp-lzo wasn't the same on local en server side.
reconfiguration with on both side "comp-lzo yes", it works all smoothly and well.

The only thing i have left is:

MULTI: bad source address from client [::], packet dropped

Thanks for all the advice and especially the command logread -e openvpn will never forget it, thanks!

You get the message as it, or in

[::]

is real IP of client? It should be real IP, so OpenVPN-server (router) doesn't have route to this network. Add route.

The discussion might have continued from here.