Skip to content

Instantly share code, notes, and snippets.

@jordelver
Created July 8, 2012 22:06
Show Gist options
  • Save jordelver/3073101 to your computer and use it in GitHub Desktop.
Save jordelver/3073101 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 :(

Set the SOCKS proxy to local SSH tunnel

networksetup -setsocksfirewallproxy "Ethernet" localhost 8080

To clear the domain and port

networksetup -setsocksfirewallproxy "Ethernet" "" ""

To turn the SOCKS proxy off

networksetup -setsocksfirewallproxystate "Ethernet" off
@madgen
Copy link

madgen commented Jan 8, 2016

Thank you!

@luckypoem
Copy link

hi.

yudeMacBook-Air:~ brite$ networksetup -setsocksfirewallproxy "Ethernet" localhost 1080
** Error: The parameters were not valid.
yudeMacBook-Air:~ brite$

你的命令“networksetup -setsocksfirewallproxy "Ethernet" localhost 8080”不对吧?

Copy link

ghost commented May 31, 2016

@luckypoem
EN: You have to execute networksetup -listnetworkserviceorder first to identified which network card you want to set
then change the Ethernet to your card id.

中文: 你必需要先執行networksetup -listnetworkserviceorder這道命令來找出你要設定的那個介面卡的名稱
然後再把Ethernet取代成你要的那名稱

EN: Example: If I want to set "Thunderbolt Ethernet 1" to sock proxy on port 2228

中文: 範例: 如果我想要把 "Thunderbolt Ethernet 1" 設成我設定的名稱

username@mymac.local:~$> networksetup -listnetworkserviceorder
(1) Thunderbolt Ethernet 1
(Hardware Port: Thunderbolt Ethernet, Device: en2)

(2) Thunderbolt Ethernet 2
(Hardware Port: Thunderbolt Ethernet, Device: en2)

username@mymac.local:~$> networksetup -setsocksfirewallproxy "Thunderbolt Ethernet 1" localhost 2228

@chinenye2017
Copy link

bro how do i buy ssh ip user ip +user +pass

@chinenye2017
Copy link

bro how do i buy ssh ip user ip +user +pass

@chinenye2017
Copy link

i need SOCKS for tunnel

@chinenye2017
Copy link

SSH tunnel

@luckypoem
Copy link

@ghost
today i just saw ur comment.
thank you.

@mikdatdogru
Copy link

socks5.sh

 #!/bin/bash
disable_proxy()
{
        networksetup -setsocksfirewallproxystate Wi-Fi off
        networksetup -setsocksfirewallproxystate Ethernet off
        echo "SOCKS proxy disabled."
}
trap disable_proxy INT
 
networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 8080
networksetup -setsocksfirewallproxy Ethernet 127.0.0.1 8080
networksetup -setsocksfirewallproxystate Wi-Fi on
networksetup -setsocksfirewallproxystate Ethernet on 
networksetup -setproxybypassdomains Wi-Fi youtube.com whatismyipaddress.com  ###excluded domains. if you do not want delete this line###
echo "SOCKS proxy enabled."
echo "Tunneling..."
ssh -ND 8080 root@xxx.xxx.xxx.xxx

and then chmod a+x /path/socks5.sh

@finagin
Copy link

finagin commented Jul 23, 2019

Update this line, save as /usr/bin/socks and run:

$ socks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment