Automating static route configuration to bypass your VPN on Mac

By X-51 | Miscellaneous Debris | 28 Mar 2021


Almost a year ago I wrote about how to bypass your VPN for specific sites on Mac, so you can have your VPN on for other network traffic while still being able to tip here on Publish0x. It is also useful for some other sites and services like accessing Brave's ad servers in case your VPN (like mine) is preventing you from downloading the ad catalog.

But sometime since writing that post my static routes for Publish0x stopped working, and my static routes for Brave's ad servers were working sometimes but not others. With a quick bit of investigation I realized that Publish0x's domain no longer resolved to the same IP address I had set up in my routes, and Brave's ad servers resolved to some of the same IPs but also to some new ones.

Instead of manually updating the static routes now, then waiting until I have issues again and updating them manually again, and repeating this process every few months until I either die of boredom or stop using the sites/services, I decided to look into automating the process so I can fix the problem once and then it will stay fixed.

 

So with a bit of work I soon had a script written up in Python, and I figured it would be good to share it with people.

 

A few words of warning:

  • Installing and automating the script requires some command line knowledge (specifically how to install a python package and how to create a cron job)
  • Configuring the domains and local settings requires making minor changes to bits of code and may require some command line stuff (this is documented in the README file)
  • The script itself is all about setting up more advanced networking configuration

So if any of those are beyond you, please strongly consider before you try this out.

 

With the warnings out of the way you can find the code plus instructions to install, configure, and schedule it on my GitLab.

 

I'm in the process of adding support for Windows, and I hope to have that ready to release within the next week.

How do you rate this article?

0


X-51
X-51

Software developer, musician, photographer, traveler, crypto enthusiast


Miscellaneous Debris
Miscellaneous Debris

If it doesn't fit one of my other blogs, then it will end up here!

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.