Heads up! This post was written 9 years ago. Some information might be outdated or may have changed since then.
Probably good option is to use some other VPN clients like "Shimo" but there is other quick and simple solution.
Solution is pretty simple, because I'm using PPTP for VPN which is basically "pppd" program, I can create a script in "/etc/ppp/ip-up" with execution permissions, for example:
cd /etc/ppp
sudo touch ip-up
sudo chmod +x ip-up And file content can be: #!/bin/sh
if [ "${5:-}" = "192.168.89.255" ]
then
/sbin/route add 192.168.88.0/24 $5
fi IP address
192.168.89.255 is given by VPN server to me and it's same every time. When the VPN link drops, those routes are automatically removed.
More examples for ip-up script can be found at
http://www.tldp.org/HOWTO/PPP-HOWTO/x1455.html and https://ppp.samba.org/pppd.html