Skip to content

Instantly share code, notes, and snippets.

@stefreak
Created August 4, 2011 10:53
Show Gist options
  • Save stefreak/1124955 to your computer and use it in GitHub Desktop.
Save stefreak/1124955 to your computer and use it in GitHub Desktop.
OpenVPN fails to replace the default route on some UMTS/PPP connections. This script fixes the default route by adding the gateway information to the default route.
#!/bin/bash
if [ $(ip route list exact default |\
awk '/^default/ {print $2}') = dev ];
then
IF=$(ip route | awk '/^default/ {print $3}')
GW=$(ip address show $IF |\
awk '/peer/ {print $4}' | cut -d"/" -f1)
ip route replace default via $GW dev $IF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment