Local route does not leave vpn

Hello friends,

I have an openVPN server installed on the router, everything works perfectly.

I have connected my LAN to a corporate WAN, within that WAN there is an ip that I need to access, but I have all the traffic through the VPN tunnel.

I need a rule for that ip, that does not go to the tunnel and go directly to the WAN. Thank you!

Automatic add route

I do not understand what I would have to do. put more data.

config interface 'lan'
option type 'bridge'
option ifname 'eth0.1'
option proto 'static'
option netmask '255.255.255.0'
option ip6assign '60'
option ipaddr '192.168.0.1'
option dns '10 .8.35.138 8.8.8.8 '

config device 'lan_dev'
option name 'eth0.1'
option macaddr '8c: 0c: a3: 27: 56: 02'

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

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

config interface 'vpn'
option ifname 'tun0'
option proto 'none'

config switch_vlan
option device 'switch0'
option vlan '2'
option ports '4 6t'

config interface 'WAN'
option proto 'dhcp'
option ifname 'eth0.2'

if I deactivate the tunnel, it works, and I can access 10.235.71.124, which is what I need, but I lose the navigation on the internet (it has to be through the vpn in a forced way)

. /lib/functions/network.sh
network_flush_cache
network_find_wan NET_IF
network_get_gateway NET_GW "${NET_IF}"
uci -q delete network.uproute
uci set network.uproute="route"
uci set network.uproute.interface="${NET_IF}"
uci set network.uproute.target="10.235.71.0/24"
uci set network.uproute.gateway="${NET_GW}"
uci commit network
/etc/init.d/network restart
1 Like

thank you!! It has worked perfectly!

Thanks again :slight_smile:

PD:
I have not understood what I have done XD

2 Likes

You created a route for 10.135.71.0/24 to be reachable via the WAN - instead of over VPN.

2 Likes