This document describes two practical methods for creating tunnels between two servers during network disruptions or restricted environments. These methods rely on alternative networking protocols when standard TCP/SSH communication is blocked.
When standard ports like 80
and 443
are unreliable or blocked, alternative ports and tunneling protocols can be used to bypass restrictions.
- Xray-core
- Dokodemo-door protocol
Requests received on standard ports (e.g., 80
, 443
) can be forwarded to an external server using unblocked ports via the Dokodemo-door protocol. The external server then maps those requests back to their original ports and forwards them as usual.
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
nano /usr/local/etc/xray/config.json
{
"inbounds": [
{
"port": 80,
"protocol": "dokodemo-door",
"settings": {
"address": "1.2.3.4",
"port": 9090,
"network": "tcp",
"followRedirect": false
},
"sniffing": {
"enabled": false
}
}
],
"outbounds": [
{
"protocol": "freedom"
}
]
}
In cases where ICMP (ping) traffic is allowed but TCP/SSH is blocked, tunneling over ICMP can be an effective workaround.
- See: Cloudflare OSI Model
- ICMP operates at Layer 3 (Network)
- TCP/SSH requires Layer 4 or higher
wget https://github.com/esrrhs/pingtunnel/releases/download/2.8/pingtunnel_linux_amd64.zip
unzip pingtunnel_linux_amd64.zip
mv pingtunnel /usr/local/bin/pt
# /etc/systemd/system/pingtunnel-server.service
[Unit]
Description=PingTunnel Server
After=network.target
[Service]
Type=simple
ExecStartPre=/bin/bash -c '[ ! -e /var/lock/pingtunnel-server.lock ] || exit 1'
ExecStart=/bin/bash -c 'touch /var/lock/pingtunnel-server.lock && pt -type server -key 200 -maxconn 1024 -maxprt 10 -maxprb 10 -nolog 1 -noprint 1'
ExecStopPost=/bin/bash -c 'rm -f /var/lock/pingtunnel-server.lock'
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/pingtunnel-client.service
[Unit]
Description=PingTunnel Client
After=network.target
[Service]
ExecStartPre=/bin/bash -c '[ ! -e /var/lock/pingtunnel-client.lock ] || exit 1'
ExecStart=/bin/bash -c 'touch /var/lock/pingtunnel-client.lock && pt -type client -l :80 -s 156.244.5.78 -t 156.244.5.78:80 -tcp 1 -key 200 -timeout 30 -tcp_bs 524288 -tcp_mw 5000 -tcp_rst 300 -nolog 1 -noprint 1'
ExecStopPost=/bin/bash -c 'rm -f /var/lock/pingtunnel-client.lock'
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable pingtunnel-{server,client}.service
sudo systemctl start pingtunnel-{server,client}.service
sudo systemctl restart pingtunnel-{server,client}.service
sudo systemctl status pingtunnel-{server,client}.service
⚠️ Parameters like buffer sizes and timeout are optimized after extensive testing but can be modified as needed.
To verify the effective ICMP bandwidth between two servers, use nping
.
Tool: nping
nping --icmp --data-length 1400 -c 1000 --delay 1ms <Another_Server_IP>
This helps determine how much data can realistically be transmitted over an ICMP-based tunnel.
- Dokodemo-door/Xray is useful when some TCP ports are still open.
- pingtunnel is a powerful fallback when only ICMP is available.
- Understanding network layers helps diagnose and work around severe restrictions.