Using a SOCKS proxy server from an OS X system

If you wish to connect to a Socket Secure (SOCKS) proxy server from a system running Apple's OS X operating system, you can do by taking the following steps:
  1. Click on the Apple icon at the top, left-hand corner of the screen and select System Preferences.
  2. Click on Network.
  3. Select the network connection for which you wish to use a SOCKS proxy, e.g., Wi-Fi, by clicking on it.
  4. Click on the Advanced button.
  5. Click on the Proxies tab.
  6. Click on Socks Proxy to check the check box next to it and then place the IP address of the SOCKS proxy server in the Socks Proxy Server field. To the right of that field, separated by a colon, is the port field. Place the port number used for the SOCKS proxy connection in that field, e.g. 1080, which is the well-known port used for the SOCKS protocol, i.e., it is the commonly used port for SOCKS connections, but not necessarily the one that has to be used.

    Network - SOCKS Proxy Server

  7. Click on OK.

You can also change the proxy server setting, which is a system-wide setting, from within some browsers, e.g., Google Chrome, where you could take the following steps to get to the SOCKS proxy server settings window.

  1. Click on the 3 horizontal bars at the top, right-hand corner of the browser window to get a menu of options and select Settings or hit the command and comma keys simultaneously to get to the Settings options.
  2. Click on "Show advanced settings", which is at the bottom of the Settings page.
  3. Under the Network section, click on the "Change proxy settings" button.

That will take you to the System Preferences window where you can change the proxy server setting as you did above.

Alternatively, if you prefer to use a command line interface (CLI), such as you would get by running the Terminal application found in Applications/Utilities, you can use the networksetup command. You can use the networksetup -getsocksfirewallproxy networkservice command, where networkservice is a particular network service, such as Wi-Fi, to check the settings.

You can check which network services are available with the networksetup -listallnetworkservices command.

$ networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
Bluetooth DUN
Thunderbolt Ethernet
USB Ethernet
Thunderbolt Ethernet Slot 2
Wi-Fi
Bluetooth PAN
Thunderbolt Bridge

E.g., I can check on whether a SOCKS proxy is being used and the setting for the SOCKS proxy port on a MacBook Pro laptop's WiFi connection using networksetup -getsocksfirewallproxy Wi-Fi.

$ networksetup -getsocksfirewallproxy Wi-Fi
Enabled: No
Server: 127.0.0.1
Port: 1080
Authenticated Proxy Enabled: 0

In the example above, the SOCKS proxy is not being used, though the port is set to 1080 and the SOCKS proxy server IP address is the localhost address 127.0.0.1. If I had used an SSH connection from the system with the -D option, e.g. ssh -D 1080 jdoe@example.com, to an SSH server to set up the SOCKS proxy then 127.0.0.1 is the address I would specify for the SOCKS server, since it is set up on the local system and is tunneled over the SSH connection.

When it is enabled, you will see output similar to the following, if you check the SOCKS proxy state.

$ networksetup -getsocksfirewallproxy Wi-Fi
Enabled: Yes
Server: 127.0.0.1
Port: 1080
Authenticated Proxy Enabled: 0

You will still see "Enabled: No" for the web proxy state, even though the proxy server address and port may be set, if the network service is not configured currently to use a SOCKS proxy. If you are using a SOCKS proxy rather than an HTTP proxy as a proxy server, you will see "Enabled: No", if you specfy the getwebproxy parameter rather than the getsocksfirewallproxy parameter.

$ networksetup -getwebproxy Wi-Fi
Enabled: No
Server: 
Port: 0
Authenticated Proxy Enabled: 0
$

If a SOCKS proxy server isn't being used and you have created a SOCKS proxy server with a tunneled SSH connection, you can enable its use with the command shown below. Your account will need administrator-level access and you will receive a password prompt where you can enter your account's password.

$ sudo networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 1080
Password:
$

You would see the settings below, if you then checked the settings through the graphical user interface (GUI) mechanism for viewing and changing the network settings through System Preferences.

Network - SOCKS Proxy Server

If I wanted to turn SOCKS proxy server support for the Wi-Fi connection off or on, I could use -setsocksfirewallproxystate networkservice on | off. E.g.:

$ sudo networksetup -setsocksfirewallproxystate Wi-Fi off
Password:

If you issue the above command without using sudo, a GUI window will appear prompting you to provide the credentials for an account with administrator access to the system to allow the change to occur.

networksetup trying to
modify settings

To avoid that window appearing, put sudo in front of the command, so that the password prompt will appear on the command line.

If you then view the SOCKS proxy settings via the GUI interface provided from the Network option under System Settings, you would then see the following:

SOCKS Proxy disabled

Make sure you use -setsocksfirewallproxystate not -setsocksfirewallproxy, i.e., include the "state" at the end of the command. If you mistakenly use the latter, you will be setting the value for the "SOCKS Proxy Server" field to "off", instead of 127.0.0.1 or some other IP adddress or fully qualified domain name (FQDN). E.g., suppose I mistakenly issued the command below:

$ sudo networksetup -setsocksfirewallproxy Wi-Fi off
Password:
$

When I issued the networksetup -getsocksfirewallproxy command, I would see the following:

$ networksetup -getsocksfirewallproxy Wi-Fi
Enabled: Yes
Server: off
Port: 0
Authenticated Proxy Enabled: 0$

If I then attempted to access a website in the browser, I would see a message like "Unable to connect to the proxy server", since the system is still configured to use a SOCKS proxy. If I then checked the SOCKS Proxy setting through System Preferences/Network, I would see the following:

SOCKS enabled, but off

The syntax for the setsocksfirewall proxy and setsocksfirewallproxystate options are shown below:

[-setsocksfirewallproxy networkservice domain portnumber authenticated username password]
                  [-setsocksfirewallproxystate networkservice on | off]

Note: tested on a MacBook Pro with OS X Yosemite (Version: 10.0.5)

 

TechRabbit ad 300x250 newegg.com

Justdeals Daily Electronics Deals1x1 px