Skip to content

Instantly share code, notes, and snippets.

@silenceshell
Forked from jordelver/gist:3073101
Last active November 29, 2023 05:26
Show Gist options
  • Save silenceshell/d97c3d9b0ba21d71f21c3a60db1fb284 to your computer and use it in GitHub Desktop.
Save silenceshell/d97c3d9b0ba21d71f21c3a60db1fb284 to your computer and use it in GitHub Desktop.
Set the Mac OS X SOCKS proxy on the command line

Set the Mac OS X SOCKS proxy on the command line

a.k.a. what to do when your ISP starts blocking sites :(

1 ssh to remote server as a SOCKS server

ssh -D 6080 {user}@{ssh_server} -p {ssh_port}

2 Get current using device

~$ networksetup -listnetworkserviceorder
An asterisk (*) denotes that a network service is disabled.
(1) Wi-Fi
(Hardware Port: Wi-Fi, Device: en0)

(2) iPhone USB
(Hardware Port: iPhone USB, Device: en4)

(3) Bluetooth PAN
(Hardware Port: Bluetooth PAN, Device: en3)

(4) Thunderbolt Bridge
(Hardware Port: Thunderbolt Bridge, Device: bridge0)

In my situation, "Wi-Fi" is the device I am using.

3 Set the SOCKS proxy to local SSH tunnel

networksetup -setsocksfirewallproxy "Wi-Fi" localhost 6080

Then enjoy visiting those sites by safari now!


To clear the domain and port

networksetup -setsocksfirewallproxy "Ethernet" "" ""

To turn the SOCKS proxy off

networksetup -setsocksfirewallproxystate "Ethernet" off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment