
Understanding Shadowsocks
Shadowsocks is an open-source, high-performance socks5 proxy designed to bypass internet censorship. Unlike VPNs that encrypt all traffic and route it through a single server, Shadowsocks selectively encrypts traffic based on pre-defined rules, making it harder to detect and block. Its architecture is more flexible and can be easily deployed on various platforms. Before setting it up, it’s important to understand the key concepts:
- Server-side: This is where the Shadowsocks server is installed. You need a server with a public IP address and minimal firewall restrictions.
- Client-side: This is the device where you install the Shadowsocks client application. This application will connect to the server and encrypt/decrypt traffic.
- Encryption: Shadowsocks uses various encryption algorithms to protect your data. Choosing a strong and secure encryption method is crucial.
- Port: A port number is required for the client to connect to the server. Choose a non-standard port to avoid detection.
- Password: A password is used to authenticate the client with the server. Keep this password safe and secure.
Choosing a Server
Selecting the right server is crucial for a successful Shadowsocks setup. Consider the following factors:
- Location: Choose a server location that is close to your actual location but outside of the censorship zone. A closer server usually means lower latency and faster speeds.
- Bandwidth: Ensure the server has sufficient bandwidth to handle your traffic. Streaming video or downloading large files requires a server with a high bandwidth capacity.
- Reliability: Opt for a server provider with a good track record of uptime and reliability. Downtime can disrupt your internet access.
- Price: Server costs can vary significantly. Compare prices from different providers and choose a plan that fits your budget.
- Root Access: You need root access to the server to install and configure the Shadowsocks server software.
Some popular server providers include:
- DigitalOcean: Offers affordable virtual servers with various operating system options.
- Vultr: Similar to DigitalOcean, providing a range of server locations and configurations.
- Amazon Web Services (AWS): A more complex but powerful cloud platform with a wide range of services.
- Google Cloud Platform (GCP): Another major cloud provider offering virtual machines and other services.
- Linode: Known for its simplicity and straightforward pricing.
Setting up Shadowsocks Server on Linux
This guide assumes you’re using a Linux server (e.g., Ubuntu, Debian, CentOS). The steps may vary slightly depending on your distribution.
1. Connect to your server via SSH:
Use an SSH client like PuTTY (Windows) or the terminal (macOS/Linux) to connect to your server using its IP address and your login credentials.
2. Update the system:
Run the following commands to update the package lists and upgrade existing packages:
“`bash
sudo apt update
sudo apt upgrade
“`
(For CentOS, use `sudo yum update`)
3. Install Shadowsocks server:
The installation method depends on your distribution.
* Ubuntu/Debian:
“`bash
sudo apt install shadowsocks-libev
“`
* CentOS:
First, enable the EPEL repository:
“`bash
sudo yum install epel-release
“`
Then, install Shadowsocks:
“`bash
sudo yum install shadowsocks-libev
“`
4. Configure Shadowsocks server:
Create a configuration file:
“`bash
sudo nano /etc/shadowsocks-libev/config.json
“`
Paste the following configuration into the file, replacing the placeholders with your desired values:
“`json
{
“server”: “0.0.0.0”,
“server_port”: 8388,
“local_address”: “127.0.0.1”,
“local_port”: 1080,
“password”: “your_strong_password”,
“timeout”: 300,
“method”: “aes-256-cfb”
}
“`
Explanation:
- `server`: The IP address the server will listen on (0.0.0.0 means all interfaces).
- `server_port`: The port the server will listen on. Choose a non-standard port.
- `local_address`: The local address the server will bind to.
- `local_port`: The local port the server will bind to.
- `password`: Your password for authentication. Choose a strong password.
- `timeout`: Connection timeout in seconds.
- `method`: Encryption method. `aes-256-cfb` is a good choice. Other options include `aes-128-cfb`, `chacha20-ietf-poly1305`, and `rc4-md5`. RC4-MD5 is not recommended due to security vulnerabilities.
Save the file and exit the editor.
5. Start and enable Shadowsocks service:
“`bash
sudo systemctl start shadowsocks-libev
sudo systemctl enable shadowsocks-libev
“`
6. Check the status of the service:
“`bash
sudo systemctl status shadowsocks-libev
“`
This command will show you if the service is running correctly.
7. Configure Firewall (if necessary):
If your server has a firewall enabled (e.g., `ufw` on Ubuntu, `firewalld` on CentOS), you need to allow traffic on the port you specified in the configuration file.
* Ubuntu (ufw):
“`bash
sudo ufw allow 8388/tcp
sudo ufw enable
“`
(Replace 8388 with your chosen port.)
* CentOS (firewalld):
“`bash
sudo firewall-cmd –permanent –add-port=8388/tcp
sudo firewall-cmd –reload
“`
(Replace 8388 with your chosen port.)
Setting up Shadowsocks Client
Now that the server is set up, you need to install a Shadowsocks client on your device. There are clients available for various platforms:
- Windows: Shadowsocks (maintained by Shadowsocks), Netch
- macOS: ShadowsocksX-NG, Shadowsocks for macOS
- Android: Shadowsocks
- iOS: Shadowrocket, Potatso Lite, Outline (requires server setup)
- Linux: Shadowsocks-libev (same as server), Qv2ray
The following steps are generally similar across different client applications:
1. Download and install the Shadowsocks client for your operating system.
2. Open the client application.
3. Configure the client with the following information:
* Server Address: Your server’s IP address.
* Server Port: The port you specified in the server configuration file (e.g., 8388).
* Password: The password you set in the server configuration file.
* Encryption Method: The encryption method you selected in the server configuration file (e.g., `aes-256-cfb`).
* Local Address (optional): Usually defaults to 127.0.0.1.
* Local Port (optional): Usually defaults to 1080.
4. Enable the Shadowsocks proxy. This typically involves toggling a switch or clicking a “Connect” button.
5. Configure your browser or operating system to use the Shadowsocks proxy.
Configuring Browser Proxy
To use Shadowsocks with your browser, you need to configure the browser to use the SOCKS5 proxy provided by the Shadowsocks client.
1. Using Browser Extensions:
The easiest way is to use a browser extension like SwitchyOmega (available for Chrome and Firefox).
* Install SwitchyOmega.
* Create a new profile in SwitchyOmega.
* Set the profile type to “SOCKS5”.
* Set the server address to 127.0.0.1.
* Set the server port to the local port specified in your Shadowsocks client (usually 1080).
* Enable the profile.
* Configure rules in SwitchyOmega to automatically use the proxy for specific websites or domains. This is more efficient than routing all traffic through the proxy. You can use a predefined blocklist, or create custom rules based on your needs.
2. Manual Browser Configuration:
You can also configure the proxy settings manually in your browser’s settings. The exact steps may vary depending on your browser.
* Chrome: Go to Settings -> System -> Open your computer’s proxy settings.
* Firefox: Go to Options -> General -> Network Settings -> Settings.
* Select “Manual proxy configuration”.
* Enter 127.0.0.1 as the SOCKS Host.
* Enter the local port specified in your Shadowsocks client (usually 1080) as the Port.
* Select “SOCKS v5”.
* Make sure “Proxy DNS when using SOCKS v5” is checked (this is crucial for preventing DNS leaks).
Configuring System-Wide Proxy (Not Recommended for General Use)
Configuring a system-wide proxy routes all traffic through the Shadowsocks proxy. This can be convenient but may also impact performance and expose more of your traffic to the proxy server. It’s generally recommended to use browser extensions or application-specific proxy settings instead.
Windows:
* Go to Settings -> Network & Internet -> Proxy.
* Enable “Use a proxy server”.
* Enter 127.0.0.1 as the Address.
* Enter the local port specified in your Shadowsocks client (usually 1080) as the Port.
* Consider adding exceptions for local network traffic.
macOS:
* Go to System Preferences -> Network.
* Select your network connection.
* Click “Advanced”.
* Go to the “Proxies” tab.
* Check “SOCKS Proxy”.
* Enter 127.0.0.1 as the SOCKS Proxy Server.
* Enter the local port specified in your Shadowsocks client (usually 1080) as the Port.
Linux:
* Setting a system-wide proxy on Linux varies depending on your desktop environment. You typically need to modify environment variables or use a GUI tool like `dconf-editor`. This is more complex and not recommended for novice users.
Testing Your Setup
After setting up Shadowsocks and configuring your browser or system proxy, you should test if it’s working correctly.
1. Check your IP address:
Visit a website like `whatismyip.com` or `ipinfo.io` before and after enabling the Shadowsocks proxy. Your IP address should change to the IP address of your server when the proxy is active.
2. Test website access:
Try accessing websites that are blocked in your region. If you can access them successfully, Shadowsocks is working.
3. Check for DNS leaks:
Visit a website like `dnsleaktest.com` and run the extended test. The results should only show your server’s DNS servers, not your ISP’s DNS servers. If you see your ISP’s DNS servers, you have a DNS leak, which can compromise your privacy. Make sure “Proxy DNS when using SOCKS v5” is checked in your browser’s proxy settings to prevent this.
Troubleshooting
If you encounter problems setting up or using Shadowsocks, consider the following troubleshooting steps:
- Verify server configuration: Double-check the configuration file on your server for any typos or errors. Ensure the password, port, and encryption method are correct.
- Check server status: Make sure the Shadowsocks server service is running on your server. Use `sudo systemctl status shadowsocks-libev` to check its status.
- Firewall issues: Ensure that your server’s firewall is allowing traffic on the port you specified for Shadowsocks.
- Client configuration: Verify that the Shadowsocks client is configured correctly with the correct server address, port, password, and encryption method.
- DNS leaks: Perform a DNS leak test to ensure that your DNS requests are being routed through the proxy server.
- Connectivity issues: Try pinging your server’s IP address from your client device to check for basic network connectivity.
- Encryption method: Ensure the encryption method selected on both the client and server side are the same.
- Check Logs: Examine the Shadowsocks server logs (usually located in `/var/log/shadowsocks-libev/`) for any error messages.
Security Considerations
While Shadowsocks is designed to bypass censorship, it’s important to be aware of the following security considerations:
- Strong password: Use a strong and unique password for your Shadowsocks server. Avoid using easily guessable passwords.
- Encryption method: Choose a secure encryption method like `aes-256-cfb` or `chacha20-ietf-poly1305`. Avoid weaker methods like `rc4-md5`.
- Server security: Secure your server by keeping it updated with the latest security patches and configuring a firewall.
- DNS leaks: Prevent DNS leaks by configuring your browser or operating system to use the proxy for DNS requests.
- Traffic analysis: While Shadowsocks encrypts your traffic, sophisticated adversaries may still be able to analyze traffic patterns to identify Shadowsocks connections.
- Server Location: Be mindful of the jurisdiction of your server location. Some countries may monitor or intercept internet traffic.