Since you didnt post the routing table once you are connected to vpn ill assume that vpn interface is tun0.
ill assume that ppp0 is interface that have direct access to the internet.
so theres a few way you can do it:
1. you should know the public IP (internet ip) of the vpn that you are connecting to.
ill assume that your default route is right now :
Code:
/sbin/route add default dev ppp0
then you do
Code:
/sbin/route add -host (ip of vpn) dev ppp0
/sbin/route del default dev ppp0
/sbin/route add default dev tun0
then by executing
Code:
traceroute www.google.com
you can see that the net traffic will go now through vpn. it will show gateway ip of vpn.
now lets say that gateway of vpn is 10.10.0.1
2. slightly better way would be to define routing like this:
Code:
route add -net 0.0.0.0 netmask 128.0.0.0 gw 10.10.0.1 dev tun0
route add -net 128.0.0.0 netmask 128.0.0.0 gw 10.10.0.1 dev tun0
/sbin/route add -host (ip of vpn) dev ppp0
Now first way is good if you really want to test how good is connection between you and vpn ex how long will vpn connection lasts. and when connection drops you will not have access to the internet unless you remove newly created route for vpn and make default route to be ppp0 if ppp0 is of course your default interface that have access to the internet.
and Second way is better because you dont have to remove the old route which is now ppp0 but because its greatly defined it takes precedence over current default route and if vpn connection drops, or you disconnect from the vpn you will still have access to the internet, because your old route which is ppp0 will remain intact.