Build ShadowsocksR on Ubuntu 20.04 Server

To bypass censorships, we can connect to a server located in a foreign country. Here’s how we can do this using Oracle Cloud Infrastructure and ShadowsocksR. This article is more like a FAQ on some problems I encountered when setting up the server. Hope this article can help you if you are facing the same issues.

You got the Oracle server, you feel excited, you feel like there’s some space that you can be yourself and leave your trace on the internet. (At least this is what I thought) Then you want to test if your server can connect to the internet, after all, to use ShadowsocksR, you need internet connection.

You typed

ping 8.8.8.8

And it returned nothing. Why? That’s because of the network setting of your server, which blocks ICMP connection.

When creating an instance on Oracle, there’s a small section where you can define your Virtual Cloud Network, and the default VNC allows ICMP, which means you should be able to ping 8.8.8.8.

However, if you have ever tried to deploy a WordPress website using Oracle’s Quickstart, Oracle will create another VCN for you which, by default, blocks ICMP.

Therefore, keep in mind that you have to change the VCN under Networking section when creating an instance. Or you can edit the VCN you are currently using to allow for ICMP.

Then, our journey begins. You can use the following code to update your existing packages and install ShadowsocksR

sudo apt update

sudo apt upgrade

sudo su

Wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh

Chmod +x shadowsocks-all.sh

./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log

Then you will enter a process pretty similar to Setup Wizzard on Windows. You can keep everything as default but remember to provide a strong password at the first step.

After you finish with these initial settings, the installation will begin. Later, when it is completed, you will see a summary of your ShadowSocksR, with ip address, password, authentication method, obfuscation method and so on.

Then you can use some apps, e.g. Potatso or ShadowRocket for iOS, to connect to your server. The problem is, it seems like when you are connected, you lost your internet connection.

If you are using ShadowRocket, there’s an option where you can test you connectivity, which will show you a timeout warning.

If you try to see which port is listening butt executing the following code, you may see that the port you set ( in my case it’s 10202) is not working.

sudo lsof -i :port_number

This is the cause of your loss of connection. You are actually not connected!

To solve this problem, I suggest doing the following two things.

First, allow the port (e.g. 10202) in ufw by

sudo ufw enable
sudo ufw allow 10202
sudo reboot

Second, add an ingress rule on Oracle. In the instance details page, find the Virtual Cloud Network, click that. In the Subnets section, click the name. In the Security Lists section, click name again. In the Ingress Rules section, click add ingress rules and input 0.0.0.0/0 in Source CIDR and 10202 in Destination Port Range.

After these two steps, you can now actually connect to you ShadowSocksR server!


Posted