I manage several OpenWrt (embedded linux) routers for which I've written bash scripts to run an Openconnect VPN client. The client uses "vpnc-script" to set up routing, which replaces the initial DHCP-provided default route.
My problem is that when the tunnel collapses, or the process is killed, the default route does not get reset, leaving the router with no default route for reconnection.
I have been solving this so far by manually setting a variable with the gateway's IP address. However, I don't think this should be necessary; and furthermore, when the router is moved (to provide a VPN connection behind another gateway), the gateway variable has to be manually changed in the script.
Since the default route is set up correctly (automatically) when the router boots, I'm sure there must be an easy way to trigger it later, but for the life of me I can't find it!
Is there an easy way to tell a linux system to reset the default route?