IPv4 Routes Not Respected in OpenConnect VPN: A Race Condition
When using OpenConnect VPN to connect to a campus network, you may encounter an issue where specific subnets are not properly routed. This article will dive into the root cause of this issue and provide a potential workaround.
OpenConnect VPN
OpenConnect VPN is an open-source client that provides remote access to many popular VPN servers. It's often used in enterprise environments and can be configured to route specific subnets through the VPN while others go through the local network.
Race Condition
The specific issue being discussed here is a race condition in the VPN client's script. A race condition occurs when multiple processes access shared data and try to change it at the same time. This can result in unexpected behavior and issues, as seen with specific subnets not being routed correctly.
Modified Connection Script
The issue arises when you modify the vpnc-win.js script to split the network and route specific subnets through the VPN.
```vbnet
start_vpnc_process = function() {
...
// Add a route for every specific subnet you want to route through the VPN here.
// For example:
// ncm.addroute('10.0.0.0/8', 'eth0');
...
}
```
This script sets up routes for specific subnets, but there's a race condition between when the routes are added and when the VPN connection is established. As a result, some subnets may not be properly routed.
Workaround
To address this issue, you can add a slight delay before adding the routes so that the VPN connection has enough time to establish. This can be done by modifying the script as follows:
By adding a delay, the VPN client has enough time to establish a connection before the routes are added, ensuring that they are properly routed.
- OpenConnect VPN is an open-source client that provides remote access to VPN servers.
- A race condition in the connection script can cause specific subnets not to be routed properly.
- Adding a delay before adding the routes in the connection script can resolve the issue.