Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mortezae/26d28090106bedffb4b3ebba3c78a80d to your computer and use it in GitHub Desktop.
Save mortezae/26d28090106bedffb4b3ebba3c78a80d to your computer and use it in GitHub Desktop.
V2ray Tunnels
V2ray Tunnels
install v2ray
sudo apt install speedtest-cli
apt-get update -y && apt-get upgrade -y
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*
dpkg --configure -a
sudo dpkg --configure -a
sudo apt update -y
apt install curl socat -y
curl https://get.acme.sh | sh
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
~/.acme.sh/acme.sh --register-account -m x@gmail.com
~/.acme.sh/acme.sh --issue -d srv.soheilsec.com --standalone
~/.acme.sh/acme.sh --installcert -d srv.soheilsec.com --key-file /root/private.key --fullchain-file /root/cert.crt
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)
21 x-ui
22 x-ui statys
23 x-ui status
24 service autossh status
25 ls
26 history
ufw disable
sudo apt install iptables-persistent -y
sudo systemctl is-enabled netfilter-persistent.service
sudo systemctl enable netfilter-persistent.service
sudo systemctl start netfilter-persistent.service
sudo systemctl status netfilter-persistent.service
~/.acme.sh/acme.sh --installcert -d srv.soheilsec.com --key-file /root/private.key --fullchain-file /root/cert.crt
way 0)
dokodemo-door
Way 1)
https://github.com/shinya-dono/shiChain
vmess Tunnel
[
{
"tag": "proxy",
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "1.1.1.1",
"port": 443,
"users": [
{
"id": "b0f6eea8-e1e1-4a62-a39c-0035366df270",
"alterId": 0,
"email": "a@a.com",
"security": "auto",
"encryption": "none",
"flow": ""
}
]
}
]
},
"streamSettings": {
"network": "tcp",
"security": "none"
}
},
{
"tag": "direct",
"protocol": "freedom",
"settings": {}
},
{
"tag": "block",
"protocol": "blackhole",
"settings": {
"response": {
"type": "http"
}
}
}
]
vless Tunnel
[
{
"tag": "proxy",
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "109.104.154.73",
"port": 59532,
"users": [
{
"id": "620c215b-bf38-4f3a-885e-6708184c8999",
"alterId": 0,
"email": "a@a.com",
"security": "auto",
"encryption": "none",
"flow": ""
}
]
}
]
},
"streamSettings": {
"network": "tcp",
"security": "none"
}
},
{
"tag": "direct",
"protocol": "freedom",
"settings": {}
},
{
"tag": "block",
"protocol": "blackhole",
"settings": {
"response": {
"type": "http"
}
}
}
]
Way2)iptables
ufw disable
sudo apt install iptables-persistent -y
sudo systemctl is-enabled netfilter-persistent.service
sudo systemctl enable netfilter-persistent.service
sudo systemctl start netfilter-persistent.service
sudo systemctl status netfilter-persistent.service
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P INPUT ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp --dport 57723 -j DNAT --to-destination 109.104.154.73:57723
service iptables save
service iptables restart
Way3)ssh
ssh-keygen
ssh-copy-id -p 2202 root@109.104.154.73
ssh-copy-id -p 2202 root@188.121.112.54
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P INPUT ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Local Forwarding
sudo ssh -p 2202 -f -N -L 0.0.0.0:57723:109.104.154.73:57723 root@109.104.154.73
Remote Forwarding SSH Reverse Tunnel
echo "GatewayPorts yes" >> /etc/ssh/sshd_config
service ssh restart
sudo ssh -p 2202 -f -N -R 0.0.0.0:25166:localhost:25166 root@188.121.112.54
apt install autossh -y
Local
cat > /etc/systemd/system/autossh.service <<EOF
[Unit]
Description=AutoSSH tunnel
After=network.target
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -N -M 10984 -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -p 2202 root@109.104.154.73 -L 0.0.0.0:57723:109.104.154.73:57723 -i /root/.ssh/id_rsa
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start autossh
systemctl enable autossh
systemctl status autossh
Remote
cat > /etc/systemd/system/autossh.service <<EOF
[Unit]
Description=AutoSSH tunnel
After=network.target
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -N -M 10984 -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -p 2202 root@188.121.112.54 -R 0.0.0.0:57723:0.0.0.0:57723 -i /root/.ssh/id_rsa
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start autossh
systemctl enable autossh
systemctl status autossh
Way 4) Stunnel
apt install stunnel4 openssl -y
#IRAN
nano /etc/stunnel/stunnel.conf
####
pid = /etc/stunnel/stunnel.pid
client = yes
output = /etc/stunnel/stunnel.log
[v2ray]
accept = 6600
connect = 109.104.154.73:14558
####
sudo systemctl restart stunnel.service
sudo systemctl enable stunnel.service
sudo systemctl status stunnel.service
#Kharej
nano /etc/stunnel/stunnel.conf
####
cert = /etc/stunnel/stunnel.pem
pid = /etc/stunnel/stunnel.pid
output = /etc/stunnel/stunnel.log
[v2ray]
accept = 14558
connect = 0.0.0.0:57723
####
cat > /etc/stunnel/stunnel.pem <<EOF
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAu2TfW5tUaXv1nNzGK/6AK2IjDhF0D8MhNYtVNLW2zK8oLLFo
14jLh5qWiCh1ZgDy5Q8sX2N9OD93W8Fim4nVGqEZjK1ieu59LclrkhkbOZwHqp6o
JwWzy/wrRTFrDAxy587ZCfas4F8rdhGqh5WEEDg4jgQLYT6M4ldUTm7DNn8TjKlc
PYfus8h+nbhD+G2l7F9LPU6BdugUCuiK+dHh6nTJpFs8ngbKzvbrc //qsHZKMnri
AxWG1eIx5av6taKgHrukwGcXPmNlCkYpvzyJM7etbQXDe7stVTcApA1FzLIP5fI1
kl+7OYgodnj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7IKpD1o46qG
pZhfCAw/QWd2MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAJTiqShs
ZLgTMgcn+WpYaXH2qrkHeqE9IbS0NjcpTp62WOqJsYDXtbBzNKrnavqsbT9vUjRX
dRoUTgRyMW7Y7+Xzc8a/aLWKYzxdREO2muCCp+xDhHsjzst2BRmaotuYuGgYIdJH
DlDYq/b6Exv/SwctxVq //fYccLtFnLM9ZcM3VScMr5gG0L2Rtcsyr/v4SfE9we71
5UKFrSO5J5Dx2pKzAmybe/anZibCeHxSIi57IxpqjKWCIdRd3cXY5iV7rPIt3Mm/
eRYbUcWWyncnJQ+hlAzlzlw6PQhUXOxb0pTPpli8w4pK7+puIzVUAh0pku1ITmwC
VVEgBfzD4bXxzCc=
-----END CERTIFICATE-----
EOF
chmod 0400 /etc/stunnel/stunnel.pem
nano /usr/lib/systemd/system/stunnel.service
####
[Unit]
Description=SSL tunnel for network daemons
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=stunnel.target
[Service]
Type=forking
ExecStart=/usr/bin/stunnel /etc/stunnel/stunnel.conf
ExecStop=/usr/bin/pkill stunnel
# Give up if ping don't get an answer
TimeoutSec=600
Restart=always
PrivateTmp=false
#####
sudo systemctl restart stunnel.service
sudo systemctl enable stunnel.service
sudo systemctl status stunnel.service
#### TLS ERROR version TLS avaz konid!
nano /etc/ssl/openssl.cnf
avale khat ino bezarid:
openssl_conf = default_conf
akhare file ham ino bezarid:
####
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1.2
CipherString = DEFAULT@SECLEVEL=1
####
Way 5)socat
apt install socat -y
nohup socat TCP4-LISTEN:1234 TCP4:109.236.91.75:1234 &
nano /usr/lib/systemd/system/socat.service
####
[Unit]
Description=Socat tunnel for network daemons
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=socat.target
[Service]
Type=forking
ExecStart=/usr/bin/socat TCP4-LISTEN:57723 TCP4:109.104.154.73:57723
ExecStop=/usr/bin/pkill socat
# Give up if ping don't get an answer
TimeoutSec=600
Restart=always
PrivateTmp=false
#####
sudo systemctl restart socat.service
sudo systemctl enable socat.service
sudo systemctl status socat.service
Way 6)gost
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P INPUT ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
wget https://github.com/ginuerzh/gost/releases/download/v2.11.5/gost-linux-amd64-2.11.5.gz
chmod +x gost
gunzip gost-linux-amd64-2.11.5.gz
chmod +x gost-linux-amd64-2.11.5
mv gost-linux-amd64-2.11.5 /usr/local/bin/gost
Gost as a Service
nano /usr/lib/systemd/system/gost.service
[Unit]
Description=GO Simple Tunnel
After=network.target
Wants=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/gost
[Install]
WantedBy=multi-user.target
==================================================
===================================================
gost -L rtcp://:25166/109.104.154.73:25166
nano /usr/lib/systemd/system/gost.service
[Unit]
Description=GO Simple Tunnel
After=network.target
Wants=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/gost -L rtcp://:57723/109.104.154.73:57723
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl restart gost
systemctl status gost
===================================================
https://v2.gost.run/en
Wss+Relay
Server Kharej
gost -L=relay+wss://:8420/:25166
server iran
gost -L=tcp://:8080 -F relay+wss://109.104.154.73:8420
========================
KCP + Relay + Tunnel
Kharej
gost -L relay+kcp://:8080
IRAN
gost -L tcp://:57723/127.0.0.1:57723 -F relay+kcp://109.104.154.73:8080
==================================================
WAy 7) wstunnel
wget "https://github.com/erebe/wstunnel/releases/download/v5.0/wstunnel-linux-x64"
chmod +x wstunnel-linux-x64
mv wstunnel-linux-x64 wstunnel
mv wstunnel /usr/local/bin/
Age domain Cloudflare darid porthai directadmin cpanel javab mide= > 80,8080,8880,2052,2082,2092,2095
-------------------------------------------
KHAREJ :
wstunnel --server ws://0.0.0.0:8080 -v
IRAN:
wstunnel -L [src_ip]: [src_port]: [dst_ip]: [dst_port] ws://[server_adress_or_domain]:[port] -v
wstunnel -L 0.0.0.0:57723:localhost:57723 -L 0.0.0.0:443:localhost:443 ws://109.104.154.73:8080 -v
-------------------------------------------
*Create systemd service for start in starup:
nano /etc/systemd/system/wstunnel.service
-->
[Unit]
Description=wstunnel Simple Tunnel
After=network.target
Wants=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/wstunnel -L 0.0.0.0:25166:localhost:25166 -L 0.0.0.0:443:localhost:443 ws://109.104.154.73:8080 -v
[Install]
WantedBy=multi-user.target
-------------------------------------------
systemctl daemon-reload
systemctl enable wstunnel.service
systemctl start wstunnel.service
systemctl status wstunnel.service
Way 8 ) TCP forwarder
https://github.com/benyamin218118/tcpforwarder/
wget https://github.com/benyamin218118/tcpforwarder/raw/main/tcpforwarder
chmod +x ./tcpforwarder
./tcpforwarder -lPort 57723 -rHost 109.104.154.73 -rPort 57723
nano /etc/systemd/system/tcpforwardersvc.service
[Unit]
Description=tcpforwarder service
After=network-online.target
Wants=network-online.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=16
User=root
ExecStart=/root/tcpforwarder -lPort 4242 -rHost mysub.domain.com -rPort 5080
[Install]
WantedBy=multi-user.target
systemctl enable tcpforwardersvc
systemctl start tcpforwardersvc
systemctl status tcpforwardersvc
WAy 9 ) ICMP Tunnel
wget https://raw.githubusercontent.com/sangscript/icmptun/main/ICMP.zip
apt install unzip -y
unzip ICMP.zip
chmod +x indexICMP
mv indexICMP /usr/local/bin/
cat > /etc/systemd/system/icmpS.service <<EOF
[Unit]
Description = Pingtunnel Iran
After = syslog.target network-online.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/indexICMP -type server
ExecReload=/bin/kill -HUP
ExecStop=/usr/bin/killall -9 indexICMP
Restart= on-failure
[Install]
WantedBy = multi-user.target
EOF
systemctl enable icmpS
systemctl start icmpS
systemctl status icmpS
cat > /etc/systemd/system/icmpC.service <<EOF
[Unit]
Description = Pingtunnel Iran
After = syslog.target network-online.target
[Service]
Type = simple
User = root
ExecStart = /usr/local/bin/indexICMP -type client -l :57723 -s 109.104.154.73 -t 109.104.154.73:57723 -tcp 1
ExecReload = /bin/kill -HUP
ExecStop = /usr/bin/killall -9 indexICMP
Restart = on-failure
[Install]
WantedBy = multi-user.target
EOF
systemctl enable icmpC
systemctl start icmpC
systemctl status icmpC
way 10) fake TLS
https://github.com/raykaryshyn/FakeTLS
https://github.com/radkesvat/FakeTlsTunnel
IRAN
wget "https://raw.githubusercontent.com/radkesvat/FakeTlsTunnel/master/install.sh" -O install.sh && chmod +x install.sh && bash install.sh
chmod +x FTT
mv FTT /usr/local/bin/
FTT --tunnel --lport:443 --toip:109.104.154.73 --toport:443 --sni:medium.com --password:soheilsec
kharej
wget "https://raw.githubusercontent.com/radkesvat/FakeTlsTunnel/master/install.sh" -O install.sh && chmod +x install.sh && bash install.sh
FTT --server --lport:443 --toip:127.0.0.1 --toport:57723 --sni:medium.com --password:soheilsec
way 11) reverse TLS Tunnel
https://github.com/radkesvat/ReverseTlsTunnel/tree/master
https://github.com/Ptechgithub/ReverseTlsTunnel/tree/main
wget "https://raw.githubusercontent.com/radkesvat/ReverseTlsTunnel/master/install.sh" -O install.sh && chmod +x install.sh && bash install.sh
chmod +x RTT
mv RTT /usr/local/bin/
RTT --iran --lport:443 --sni:splus.ir --password:soheilsec
RTT --kharej --iran-ip:188.121.112.54 --iran-port:443 --toip:127.0.0.1 --toport:57723 --password:soheilsec --sni:splus.ir
Way 12) singbox -reality
=> install https://telegra.ph/How-run-Reality-protocol-with-Xray-or-Sing-box-Core-with-iSegaro-04-18
Server IRAN
curl -Lo /root/sb https://github.com/SagerNet/sing-box/releases/download/v1.3-beta11/sing-box-1.3-beta11-linux-amd64.tar.gz && tar -xzf /root/sb && cp -f /root/sing-box-*/sing-box /root && rm -r /root/sb /root/sing-box-* && chown root:root /root/sing-box && chmod +x /root/sing-box
config
curl -Lo /root/sing-box_config.json https://raw.githubusercontent.com/iSegaro/Sing-Box/main/sing-box_tunnel.json
service :
curl -Lo /etc/systemd/system/sing-box.service https://raw.githubusercontent.com/iSegaro/Sing-Box/main/sing-box.service && systemctl daemon-reload
./sing-box generate uuid
./sing-box generate reality-keypair
./sing-box generate rand --hex 8
nano sing-box_config.json
/root/sing-box check -c sing-box_config.json
systemctl enable --now sing-box && sleep 0.2 && systemctl status sing-box
systemctl stop sing-box
systemctl restart sing-box
systemctl start sing-box
systemctl status sing-box
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment