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!


Occasional Visitor
Hi I've set up a PPTP client that connects from a remote site ( and gets IP
I've setup a script that adds route ip route add via 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:
if [ $(ip route show | wc -l) -eq 0 ]; then

echo "--- Route is down ---"
ip route add via

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

echo "--- Route Enabled ---"

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