Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Jan 8, 2016

Thank you!

@luckypoem

This comment has been minimized.

Copy link

commented May 19, 2016

hi.

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

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

@ghost

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Apr 6, 2017

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

@chinenye2017

This comment has been minimized.

Copy link

commented Apr 6, 2017

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

@chinenye2017

This comment has been minimized.

Copy link

commented Apr 6, 2017

i need SOCKS for tunnel

@chinenye2017

This comment has been minimized.

Copy link

commented Apr 6, 2017

SSH tunnel

@luckypoem

This comment has been minimized.

Copy link

commented Apr 12, 2018

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

@mikdatdogru

This comment has been minimized.

Copy link

commented May 31, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.