Skip to content

Instantly share code, notes, and snippets.

@csanz
Created April 16, 2020 23:03
Show Gist options
  • Save csanz/74bc858268d5772c90c3aabe7efe2c92 to your computer and use it in GitHub Desktop.
Save csanz/74bc858268d5772c90c3aabe7efe2c92 to your computer and use it in GitHub Desktop.
Updating Mac OSX System Proxy via Terminal

Updating Mac OSX Proxy via the Terminal

I'm using AnyProxy to block websites on my son's computer. I also use it block safe websites like roblox or youtube, just so he can do his home work... Right now i"m seeting up a proxy with some rules and I go and ssh to turn the proxy on and off... I found this last night at 2am and put it on a gitst, but I'll make it public now.

You simply just use the networksetup command. You can find the params you need to you this way

networksetup -setwebproxy | grep "setproxy"

networksetup -setwebproxy <networkservice> <domain> <port number> <authenticated> <username> <password>
networksetup -setsecurewebproxy <networkservice> <domain> <port number> <authenticated> <username> <password>

Then look up your network services with networksetup -listallnetworkservices

Thank you update...

networksetup -setwebproxy Wi-Fi 127.0.0.1 8001
networksetup -setsecurewebproxy Wi-Fi 127.0.0.1 8001

Turn On/Off

To turn them off is also super simple

Format

networksetup -setwebproxystate <networkservice> <on off>
networksetup -setsecurewebproxystate <networkservice> <on off>

Example Turn On

networksetup -setwebproxystate Wi-Fi on
networksetup -setsecurewebproxystate Wi-Fi on

Example Turn Off

networksetup -setwebproxystate Wi-Fi off
networksetup -setsecurewebproxystate Wi-Fi off

Verify It is Set

Format

networksetup -getwebproxy <networkservice>
networksetup -getsecurewebproxy <networkservice>

Example

networksetup -getwebproxy Wi-Fi
networksetup -getsecurewebproxy Wi-Fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment