DDWRT + PPTP Client: Add routes after connection

Average: 3.5 (120 votes)

Getting routes to be added after VPN connection is established is a bit tricky at least on some DDWRT routers.

In order to add routes after PPTP connection is established you need to modify ip-up script in /tmp/pptpd_client. The problem is that this script is generated when pptpd starts.

To modify it you need to add a startup script that will wait for this file to be created and then append whatever custom routes are needed.

Assuming that PPTP Server has IP 172.16.0.1 and you want to add routes to 172.16.2.0/24 and 172.16.3.0/24 networks, saving this as startup script will do the trick:

while [ ! -f /tmp/pptpd_client/ip-up ]
do
sleep 1
done
cd /tmp/pptpd_client
cp ip-up ip-up.old
grep -v 'exit 0' ip-up.old > ip-up
echo "/sbin/route add -net 172.16.2.0/24 gw 172.16.0.1" >> ip-up
echo "/sbin/route add -net 172.16.3.0/24 gw 172.16.0.1" >> ip-up
echo "exit 0" >> ip-up

Try to reboot the router, wait for PPTP connection to come up. Check the routing table using ip route command.

glqxz9283 sfy39587stf02 mnesdcuix8
sfy39587stf03
sfy39587stf04