AndyJarrett

Turning SOCKS proxy on from the terminal on OSX

If you have to set up a SSH tunnel and a SOCKS proxy regularly to get around work firewalls (so you can post on your "blog") you can actually do this from the Terminal.app with the following setup and command

First go to System Preferences and setup you SOCKS server address

Then to turn this on and off from the terminal you can use: networksetup -setsocksfirewallproxystate Ethernet on and networksetup -setsocksfirewallproxystate Ethernet off

To be even lazier you can setup your tunnel with the following one line string (replace 10.0.0.1 with you server address):
ssh -ND 9999 root@10.0.0.1 && networksetup -setsocksfirewallproxystate Ethernet on