How to Create a SOCKS5 Proxy Server with Shadowsocks | Linode

This guide shows you how to create a SOCKS5 proxy server with Shadowsocks on Ubuntu and CentOS. Shadowsocks is a lightweight SOCKS5 web proxy tool primarily utilized to bypass network censorship and block certain websites and web protocols. A full setup requires a Linode server to host the Shadowsocks daemon, and a client installed on PC, Mac, Linux, or a mobile device.

Unlike other proxy software, Shadowsocks traffic is designed to be both indiscernible from other traffic to third-party monitoring tools, and also able to disguise as a normal direct connection. Data passing through Shadowsocks is encrypted for additional security and privacy.

Because currently, there is no Shadowsocks package available for Ubuntu or CentOS, this guide shows how to build Shadowsocks from the source.

Before You Begin

  1. The commands in this guide require root privileges. To run the steps as an elevated user with sudo privileges, prepend each command with sudo. If two commands are presented in the same instance (separated by &&), remember to use sudo after the && (ex. sudo [command] && sudo [command]). To create a standard user account with sudo privileges, complete the Add a Limited User Account section of our Securing your Server guide.

  2. A working firewall is a necessary security measure. Firewall instructions are provided for UFW, FirewallD, and Iptables. To configure a firewall on a Linode, visit one of the following guides:

    • How to Configure a Firewall with UFW
    • Introduction to FirewallD on CentOS

What Is SOCKS5 Proxy Service?

SOCKS5 is an internet protocol of SOCKS that helps to route packets through a proxy between a client and a server. To carry out a secure communication, SOCKS5 uses three different modes of authentication: Null authentication, GSS-API based authentication, and a username-password based authentication.

When SOCKS5 uses a NULL authentication, any request between client and server connects to the set proxy without requiring any authentication. With GSS API authentication, a client’s or server’s identity is verified at the OS level to authenticate.

A username and password-based authentication uses credentials to connect to the proxy.

What Is Shadowsocks?

Shadowsocks is an open source, free encryption protocol client designed to securely transmit information between clients and servers. It uses asynchronous input-output and is event-driven to deliver speed. Shadowsocks isn’t a proxy, but it enables connecting to 3rd party SOCKS5 proxy connections. It also supports UDP traffic.

Install the Shadowsocks Server

How Do You Run ShadowSocks On Ubuntu?

To run and install Shadowsocks on Ubuntu Server follow these steps:

  1. Download and update the packages to the newest versions on Ubuntu

    apt update && apt upgrade -yuf

  2. Install dependencies on the Ubuntu server by running the following command:

    apt install -y -no-install-recommends gettext build-essential autoconf libtool libpcre3-dev asciidoc xmlto libev-dev libudns-dev automake libmbedtls-dev libsodium-dev git python-m2crypto libc-ares-dev

  3. Navigate to the /opt directory on Ubuntu and download the Shadowsocks Git module:

    cd /opt git clone cd shadowsocks-libev git submodule update -init -recursive

  4. Install Shadowsocks-libev:

    ./ ./configure make && make install

How Do You Run ShadowSocks On CentOS 7?

To run and install Shadowsocks on CentOS7 follow these steps:

  1. Download and update the packages to the newest versions

    yum update && yum upgrade -y yum install epel-release -y

  2. Install dependencies on CentOS7

    yum install -y gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto udns-devel libev-devel libsodium-devel mbedtls-devel git m2crypto c-ares-devel

  3. Navigate to the /opt directory on CentOS7 and download the Shadowsocks Git module:

    cd /opt git clone cd shadowsocks-libev git submodule update -init -recursive

  4. Install Shadowsocks-libev:

    ./ ./configure make && make install

How Do You Use Shadowsocks Libev?

Shadowsocks libev is a lightweight, purely C-based proxy implementation for embedded devices. To use Shadowsocks libev after its installation, simply add a system user to Shadowsocks, create a directory with its configuration file.

Configure the Shadowsocks Server

  1. Create a new system user for Shadowsocks:

    Ubuntu 16.04

    adduser -system -no-create-home -group shadowsocks

    CentOS 7

    adduser -system -no-create-home -s /bin/false shadowsocks

  2. Create a new directory for the configuration file:

    mkdir -m 755 /etc/shadowsocks

  3. Create the Shadowsocks configuration file located at /etc/shadowsocks/shadowsocks.json. Paste the contents listed below into the file, noting the instructions in the shadowsocks.json Breakdown table for each property. Follow these instructions to determine the value you should set for each property.

    File: /etc/shadowsocks/shadowsocks.json

shadowsocks.json Breakdown

PropertyDescriptionPossible ValuesserverEnter the server’s public IP address.User determinedserver_portShadowsocks listens on this port. Use the default value of 8388.User determinedpasswordConnection password. Set a strong password.User determinedtimeoutConnection timeout in seconds. The default value should be sufficient here.User determinedmethodEncryption method. Using AEAD algorithms is recommended.See Stream Ciphers and AEAD Ciphersfast_openReduces latency when turned on. Can only be used with kernel versions 3.7.1 or higher. Check the kernel version with uname -r.true, falsenameserverName servers for internal DNS resolver.User determined

Optimize Shadowsocks

Apply the following optimizations to the system kernel to provide for a smooth running Shadowsocks installation.

  1. Create the /etc/sysctl.d/local.conf system optimization file and paste the contents shown below into the file:


    File: /etc/sysctl.d/local.conf

  2. Apply optimizations:

    sysctl -system

Create a Shadowsocks Systemd Service

The Shadowsocks systemd service allows the daemon to automatically start on system boot and run in the background.

  1. Create a systemd file with the following content:

    File: /etc/systemd/system/shadowsocks.service

  2. Enable and start shadowsocks.service:

    systemctl daemon-reload systemctl enable shadowsocks systemctl start shadowsocks

Open Firewall Port for Shadowsocks Client

Depending on your preference, you may use either the iptables, UFW, or firewalld (CentOS 7 only) commands to complete this section.

Open port 8388 for the Shadowsocks Client:


iptables -4 -A INPUT -p tcp -dport 8388 -m comment -comment “Shadowsocks server listen port” -j ACCEPT


ufw allow proto tcp to port 8388 comment “Shadowsocks server listen port”


firewall-cmd -permanent -zone=public -add-rich-rule=’ rule family=”ipv4″ port protocol=”tcp” port=”8388″ accept’ firewall-cmd -reload

Install a Shadowsocks Client

The second stage to a Shadowsocks setup is to install a client on the user’s device. This could include a computer, mobile device, tablet, and even home network router. Supported operating systems include Windows, macOS, iOS, Linux, Android, and OpenWRT.

macOS Shadowsocks Client

  1. Download the ShadowsocksX-NG GUI Client for macOS:

    Shadowsocks download page

  2. Launch the application on your Mac. The app preferences is available from a new status menu bar icon. Select the Server Preferences menu item:

  3. In the Server Preferences window, click the + (plus-sign) button in the lower left. Enter the details for your Shadowsocks Linode. Be sure to select the same port and encryption scheme that you listed in your Linode’s shadowsocks.json file. Afterwards, close the window:

  4. In the Shadowsocks menu, make sure that Shadowsocks is turned on and that the Global Mode item is selected:

    macOS Shadowsocks menu bar - Global Mode menu item
  5. Verify that the Shadowsocks connection is active by visiting an IP address lookup website like When the connection is working as expected, the website lists the Shadowsocks Linode’s public IP.

Windows Shadowsocks Client

  1. Navigate to the Windows Shadowsocks page. Click on under Downloads.

  2. Extract the contents of the .zip file into any folder and run Shadowsocks.exe. Shadowsocks runs as a background process. Locate the Shadowsocks icon in the taskbar (it may be in the Hidden Icons taskbar menu), right-click on the Shadowsocks icon, then click on Edit Servers. Enter the information that you saved in the shadowsocks.json file:

    New server configuration dialog
  3. Right-click on the Shadowsocks icon again. Mouse over PAC and select both Local PAC and Secure Local PAC.

    To confirm that the Linode’s IP address is selected, mouse over Servers.

  4. Verify that the Shadowsocks connection is active by visiting an IP address lookup website like When the connection is working as expected, the website lists the Shadowsocks Linode’s public IP.

How Do You Know If SOCKS5 Proxy Is Working?

To check if the SOCKS5 proxy is working, open the terminal and run the netstat command to see if there is an open port:

netstat -tlnp

If the SOCKS5 proxy is working, you should see an output similar to below in the terminal:

tcp 0 0 232.222.333.414:8888* LISTEN

Another way to test whether SOCKS5 proxy is working is by using the curl command on the right port of the proxy. For a SOCKS5 proxy hosted at 232.222.333.414 listening at port 8080, run the following command in the terminal:

timeout 5 curl -x socks5://232.222.333.414:8080

If the SOCKS5 proxy isn’t working properly on a proxy hosted at 232.222.333.414, it returns a timeout on our terminal.

Where to Go from Here

After the Shadowsocks server is online, configure a client on your mobile phone, tablet, or any other devices you use. The Shadowsocks client download page supports all mainstream platforms.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

  • Shadowsocks official
  • Shadowsocks-libev GitHub

Review top Ubuntu socks5 proxy client cheap 2022

Related Posts