how to you toggle on and off a web proxy in os x from the command line

前端 未结 7 1441
予麋鹿
予麋鹿 2021-01-31 15:45

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 a

7条回答
  •  無奈伤痛
    2021-01-31 16:14

    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.

提交回复
热议问题