Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save NikitaKokarev/6e8ffec98c28dfdc80df825824b12932 to your computer and use it in GitHub Desktop.

Select an option

Save NikitaKokarev/6e8ffec98c28dfdc80df825824b12932 to your computer and use it in GitHub Desktop.
Socks5 proxy setup guide.

What you will need

First of all, note that for the work of Shadowsocks, as well as for a VPN, you will need a server, in a country where the sites you need are not blocked. This server is installed on this server. On your computer or phone is a client that connects to this server. Between your client and the server, traffic will be encrypted so the provider will not be able to understand which site you open, so it will not block it. And already on the server, the request will be decrypted and in an open form will go to the site. There are several variants of the shadowsocks server. There are implementations in Python, Go and C. I will use the C version (libev).

Install Shadowsocks from repository

The implementation of shadowsocks on C is in the official Ubuntu repositories. You can install it with the command:

$ sudo apt install shadowsocks-libev

Customize shadowsocks

The shadowsocks configuration file is located on the path /etc/shadowsocks-libev/config.json Rewrite this json with your settings values:

{
    "server":"<your server ip address>",
    "server_port":8388,
    "local_address": "127.0.0.1",
    "local_port":15080,
    "password":"<your server password>",
    "mode":"tcp_and_udp",
    "timeout":10000,
    "method":"chacha20-ietf-poly1305"
}

This is what these params mean:

  • server - the IP address where the program will expect connections must match the external IP address of your server.
  • server_port - the port of the server you will use for connection, by default - 8388.
  • local_address - the IP address of the service that the browser will access.
  • local_port - the port of the client, to which the browser will be connected via the SOCS5 protocol.
  • password - a password that will be used by customers to connect.
  • mode - specifies which connection protocol to use - tcp, udp or both.
  • method - the encryption method, by default chacha20-ietf-poly1305 is used.

To start working with shadowsocks, you need to install the external IP address of your server in the server field. It can be viewed by the command:

wget -qO- eth0.me

Shadowsocks client launch

Ok. Now we are ready to launch the proxy client. Let me remind that the application consists of a server and client part. That is, many clients (proxy services) can potentially be connected to one server.

  1. We will create another one .json file with the proxy client settings. So it's easy: just copy /etc/shadowsocks-libev/config.json to the same directory with name as you wish,shadow_proxy.json as example.
  2. Launching the Shadowsocks client:
sudo systemctl enable --now shadowsocks-libev-local@shadow_proxy.service
  1. Disabling the server. Making sure that the Shadowsocks server is not active:
sudo systemctl status shadowsocks-libev.service

If the server is active, then disable it:

sudo systemctl disable --now shadowsocks-libev.service
  1. Checking the status of unit files:
sudo systemctl list-unit-files | grep shadow

You should see that only shadowsocks-libev-local@.service is enabled and the other Shadowsocks related unit files are disabled:

hadowsocks-libev-local@.service           indirect        enabled
shadowsocks-libev-redir@.service          disabled        enabled
shadowsocks-libev-server@.service         disabled        enabled
shadowsocks-libev-tunnel@.service         disabled        enabled
shadowsocks-libev.service                 disabled        enabled
  1. Now, to make sure that your client is working correctly and the proxy is working stably:
sudo systemctl status shadowsocks-libev-local@shadow_proxy.service

You should see that the client service is active and running.

Proxy start/stop

1) Firefox Web Browser

Mozilla proxy settings: Firefox Web Browser -> Settings -> Network Settings(Settings button):

  • checkbox - Manual proxy configuration
  • SOCKS Host - 127.0.0.1, Host 15080
  • checkbox - SOCKS v5
  • placeholder - No proxy for: 192.168.0.0/16
  • checkbox - Proxy DNS when using SOCKS v5

If you want to manage proxy traffic from your browser (Mozilla Firefox): Turn on "Manual proxy configuration" to enable the proxy. Turn on "No proxy" to disable the proxy.

2) Up/Down Shadowsocks client app

  • Start client:
sudo systemctl start shadowsocks-libev-local@shadow_proxy.service
  • Stop client:
sudo systemctl stop shadowsocks-libev-local@shadow_proxy.service
  • restart client:
sudo systemctl restart shadowsocks-libev-local@shadow_proxy.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment