Skip to content

Route Traffic Through Domestic Server With KCPTUN

Hirbod Behnam edited this page Jul 1, 2019 · 4 revisions

THIS TUTORIAL ONLY AND ONLY BYPASSES OUTGOING DPI AND WILL NOT MASK YOUR DOMESTIC SERVER IP

Why this?

Basically everything is just like routing with shadowsocks. But it uses kcptun to route your traffic.

Setting up KCPTUN

On Both Servers

At first edit /etc/sysctl.conf and add these lines:

net.core.rmem_max=26214400
net.core.rmem_default=26214400
net.core.wmem_max=26214400
net.core.wmem_default=26214400
net.core.netdev_max_backlog=2048

Then edit ~/.bashrc and at the very last of it add this line:

ulimit -n 65535

Restart the server after these changes.

On Foreign Server

  1. Download the related kcptun executable from here.
  2. Extract it using tar xf kcptun-linux-xxx.tar.gz
  3. Then enter the following command: (You need to run this with screen or tmux)
./server_linux_amd64 -t "127.0.0.1:1234" -l ":4321" -mode fast3 -nocomp -sockbuf 16777217 -dscp 46
  • 1234 here is the port of your proxy.
  • 4321 this is the port the server listens on. Choose this one.
  1. If your OS is Ubuntu run ufw allow 4321/udp; If your system is Centos run firewall-cmd --add-port=4321/udp && firewall-cmd --permanent --add-port=4321/udp (Change 4321 if needed)

On Domestic Server

  1. Download the related kcptun executable from here.
  2. Extract it using tar xf kcptun-linux-xxx.tar.gz
  3. Then enter the following command: (You need to run this with screen or tmux)
./client_linux_amd64 -r "1.1.1.1:4321" -l ":1234" -mode fast3 -nocomp -autoexpire 900 -sockbuf 16777217 -dscp 46
  • 1234 here is the port of your proxy. (You can change this)
  • 4321 is the port you have chosen on foreign server.
  • 1.1.1.1 is your foreign server ip address.
  1. If your OS is Ubuntu run ufw allow 1234/tcp; If your system is Centos run firewall-cmd --add-port=1234/tcp && firewall-cmd --permanent --add-port=1234/tcp (Change 1234 if needed)