I am using open connect to create a split VPN connection. It works great... the first time. If the openconnect process dies, subsequent tries appear to succeed, but leave me unable to actually access anything behind the VPN. Rebooting temporarily allows openconnect to work once again, but I'd like to be able to turn the VPN on and off without having to reboot every time.
I think the problem is related to improper closing/clean up of the VPN connection, but this is out of my depth and I have no idea what I'm doing. What is going on and how to fix it or set up a system that allows me to start and stop my VPN connection multiple times without rebooting. route produces the same output both when the VPN is working and when it isn't.
Here is the script I use to connect:
sudo openvpn --mktun --dev tun1 && \
sudo ifconfig tun1 up && \
sudo /usr/sbin/openconnect -s $VPNSCRIPT $VPNURL --user=$VPNUSER --authgroup=$VPNGRP --interface=tun1
sudo ifconfig tun1 down
openvpn --rmtun --dev tun1
where $VPNSCRIPT
is a wrapper around the default vpnc-script to set up the environment for split VPN:
#!/bin/sh # Add one IP to the list of split tunnel add_ip () { export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_ADDR=$1 export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASK=255.255.255.255 export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASKLEN=32 export CISCO_SPLIT_INC=$(($CISCO_SPLIT_INC + 1)) } # Initialize empty split tunnel list export CISCO_SPLIT_INC=0 # Delete DNS info provided by VPN server to use internet DNS # Comment following line to use DNS beyond VPN tunnel unset INTERNAL_IP4_DNS # List of IPs beyond VPN tunnel add_ip --REDACTED-- # Execute default script . /usr/share/vpnc-scripts/vpnc-script # End of script
This is all happening on a Ubuntu 14.04 VPS
results of route -n
No connection attempt:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 venet0
Connected and working
Destination Gateway Genmask Flags Metric Ref Use Iface
<HostA> 0.0.0.0 255.255.255.255 UH 0 0 0 tun1
<VPN> 0.0.0.0 255.255.255.255 UH 0 0 0 venet0
<HostB> 0.0.0.0 255.255.255.255 UH 0 0 0 tun1
<VPN DHCP> 0.0.0.0 255.255.254.0 U 0 0 0 tun1
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 venet0
Supposedly connected, but not working
Destination Gateway Genmask Flags Metric Ref Use Iface
<HostA> 0.0.0.0 255.255.255.255 UH 0 0 0 tun1
<VPN> 0.0.0.0 255.255.255.255 UH 0 0 0 venet0
<HostB> 0.0.0.0 255.255.255.255 UH 0 0 0 tun1
<VPN DHCP> 0.0.0.0 255.255.254.0 U 0 0 0 tun1
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 venet0
where Host*
is an entry in the split VPN config.