What's new

Script to add route after a VPN client connects

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

nickolasm5

Occasional Visitor
Hi I've set up a PPTP client that connects from a remote site (192.168.7.0) and gets IP 10.8.20.0
I've setup a script that adds route ip route add 192.168.7.0 via 10.8.20.0 on firewall startup, and everything works
Yet I noticed that if for some reasons there were reconnect of that client this route disappears, and expectedly doesn't appear
Is there a way to semhow set up the script ro run on pptp reconnect, or to check if the route exists periodically and add it?

BTW, I've tried to add this route via GUI, but it doesn't even show in the routing table. (I've used VPN in the interface options) Sould it work at all? Maybe I should use LAN or MAN in the interface option?
 
Last edited:
#!/bin/sh
if [ $(ip route show 192.168.7.0/24 | wc -l) -eq 0 ]; then

echo "--- Route is down ---"
ip route add 192.168.7.0/24 via 10.8.20.2
fi

if [ $(ip route show 10.10.200.0/24 | wc -l) -eq 1 ]; then

echo "--- Route Enabled ---"
fi



exit
 
You might find the following useful.

 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Top