vpn – Unable to Route All Traffic Through OpenConnect VPN

routingvpn

Feel free to give me a course correction. I'm out of my depth here.

I'm using openconnect to connect to a vpn. This creates a device tun0, which I can see when I run ip address. I've successfully added entries to my routing table with ip route add $IP_ADDR dev tun0 and been able to access servers on my vpn.

I want to try using this vpn connection as my default route, and I've seen other posts, such as the following two, which instruct me to perform a command like this: ip route add default via 192.168.30.1 dev mydevice

Well, I've tried something similar, but I omit the via $IP_ADDR because I can't find an ip address for this device:

dhclient tun0 # => outputs nothing
ip route del default
ip route add default dev tun0

…and when I do so, it appears that I can't connect to any servers at all. If I add a route that uses tun0 to my routing table without making it the default route, though, I can reach servers on the vpn for as many routing rules as I've created.

Edit: here's the output of ip route show (before trying to change the default): https://pastebin.com/0X9rqgne

Best Answer

You need to do three steps:

Add a route to the VPN server via your physical gateway so that VPN tunnel packets can reach the VPN server

ip route add <VPN server IP address> via 192.168.68.1

Delete existing default route

ip route delete default via 192.168.68.1

Add default route via the tunnel

ip route add default dev tun0

However, if the VPN server doesn't forward packets to the internet, then adding this configuration doesn't help. In that case, you need to convince the VPN server operators to forward traffic to the internet.

There are legitimate reasons why the VPN server wouldn't forward traffic to the internet.

Related Topic