Bypass system proxy when connected to VPN

Got a problem with Viscosity or need help? Ask here!

bedouin

Posts: 3
Joined: Tue Aug 20, 2013 1:52 am

Post by bedouin » Tue Aug 20, 2013 2:04 am
Hi there,

I tested the software out and was pretty impressed by its stability and overall ease and registered a copy.

One problem though: in the past when I connected using PPTP in OS X, the built-in VPN was smart enough to bypass my system wide proxy. OpenVPN on iOS does that too. Is there a way to make Viscosity ignore my system proxy settings?

James

User avatar
Posts: 2313
Joined: Thu Sep 04, 2008 9:27 pm

Post by James » Tue Aug 20, 2013 10:19 am
Hi bedouin,

Viscosity can't turn off your proxy settings directly, however you can use Viscosity's AppleScript support to do so instead. The easiest way would be to create two scripts that use the "networksetup" command to toggle your proxy settings off when you connect, and back on when you disconnect.

Firstly, see this guide for information on how to write and use AppleScript scripts in Viscosity. Then you'll need to create your Connected and Disconnected scripts. For example, if you use a standard web proxy you'll want a Connected script that looks something like:
Code: Select all
do shell script "networksetup -setwebproxystate 'Ethernet' off"
And a Disconnected script that looks something like:
Code: Select all
do shell script "networksetup -setwebproxystate 'Ethernet' on"
You should change the "Ethernet" text to the name of your network adapter if it is something else. For example Ethernet is typically your wired network connection, while "Wi-Fi" is typically the name for your wireless connection.

If you use a different type of proxy, or use multiple proxy types, you'll need to adjust or add commands accordingly. E.g. use "-setsecurewebproxystate" instead for a secure web proxy, "-setsocksfirewallproxystate" for a SOCKS proxy, etc.

Finally, networksetup may need to prompt you for admin rights to be able to make the change. If you wish to stop this behaviour you can run it directly from Viscosity with admin rights, for example:
Code: Select all
do shell script "networksetup -setwebproxystate 'Ethernet' off" user name "username" password "password" with administrator privileges
Cheers,
James
Web: https://www.sparklabs.com
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs

bedouin

Posts: 3
Joined: Tue Aug 20, 2013 1:52 am

Post by bedouin » Wed Aug 21, 2013 6:44 am
Thanks for your reply but I opted for a simpler solution: I connected the proxy itself to the VPN. Now all machines on my network can route traffic through it, and bypass my ISP's traffic shaping without violating my VPN provider's two machine limit. As an added perk I get caching and global adblocking, two things that can't hurt when connected through a VPN. Also my local network hostnames and domains remain resolvable.

There will still be cases where I want to use the VPN for more than just web traffic though, so Viscosity will still occupy a special place in my menu bar.
3 posts Page 1 of 1