How to setup VPN client routes via SSH

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.


New Around Here
My end goal is to route all traffic hitting a specific media service through my VPN client.

I've got a list of IPs that is dynamically updated using this service's various URLs.
I'd like to force any traffic coming from any device on my network that is destined for one of these IPs, to go over the VPN rather than the WAN. I realize that I can do this through the GUI, but I'm hoping there is way to do this via SSH. Since the list I've got is dynamic, I'd like to automate the update process for the IP routes.

Any help would be GREATLY appreciated!


Senior Member
My end goal is to route all traffic hitting a specific media service through my VPN client.
@Xentrk's Selective Routing script option 3 will allow you to do just that. Instructions and the script(s) at:

It can also be installed through 'amtm' item 6.


Very Senior Member
I assume you're presently using Routing Policy and this is for those clients NOT already bound to the VPN.

Since this only requires adding static routes, it' a simple matter to create a script (or even just a one-liner).

Assuming you have a file w/ a list of public IPs (one per line)...

while read ip; do ip route add $ip dev tun11; done < /path/filename

Of course, I'm assuming OpenVPN client #1 (tun11) for illustration purposes. You could get fancier and perhaps delete the old routes before adding the new ones.

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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