In OS X, you turn on and off a web proxy from System Preferences > Network > Proxies, by checking Web Proxy (HTTP) and designating the Web Proxy Server etc. and by clicking OK and then "Apply". This is way too many steps. Is there a way to do this all from the command line and a shell script?
This is equivalent to setting the proxy via mac system settings > Network > wi-fi > Advanced > Proxies > Web proxy.
For an unauthenticated proxy (and assuming it's the Ethernet service you want to configure):
networksetup -setwebproxy Ethernet proxy.example.net 80 off
for authenticated:
networksetup -setwebproxy Ethernet proxy.example.net 80 on proxyuser "p4ssw0rd"
and to turn it off:
networksetup -setwebproxystate Ethernet off
If the network service isn't named just "Ethernet", you may need to parse networksetup -listallnetworkservices
or -listnetworkserviceorder
to get the correct name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With