A simple VPN written in Go.
- VPN over udp
- VPN over websocket
- VPN over tls
- VPN over grpc
- VPN over quic
- VPN over kcp
Usage of ./vtun:
-S server mode
-c string
tun interface cidr (default "172.16.0.10/24")
-c6 string
tun interface ipv6 cidr (default "fced:9999::9999/64")
-certificate string
tls certificate file path (default "./certs/server.pem")
-privatekey string
tls certificate key file path (default "./certs/server.key")
-sni string
tls handshake sni
-isv
tls insecure skip verify
-dn string
device name
-g client global mode
-k string
key (default "freedom@2022")
-l string
local address (default ":3000")
-mtu int
tun mtu (default 1500)
-obfs
enable data obfuscation
-compress
enable data compression
-p string
protocol udp/tls/grpc/quic/kcp/ws/wss (default "udp")
-path string
websocket path (default "/freedom")
-s string
server address (default ":3001")
-sip string
server ip (default "172.16.0.1")
-sip6 string
server ipv6 (default "fced:9999::1")
-t int
dial timeout in seconds (default 30)
-v enable verbose output
scripts/build.sh
sudo ./vtun-linux-amd64 -s server-addr:3001 -c 172.16.0.10/24 -k 123456
sudo ./vtun-linux-amd64 -s server-addr:3001 -c 172.16.0.10/24 -k 123456 -g
sudo ./vtun-darwin-amd64 -s server-addr:3001 -c 172.16.0.10/24 -k 123456 -g -sip 172.16.0.1
To use it with windows, you will need to download a wintun.dll file in the app directory.
Open powershell as administrator and run cmd:
.\vtun-win-amd64.exe -s server-addr:3001 -c 172.16.0.10/24 -k 123456 -g -sip 172.16.0.1
sudo ./vtun-linux-amd64 -S -l :3001 -c 172.16.0.1/24 -k 123456
# Enable ipv4 and ipv6 forward
vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding=1
sysctl -p /etc/sysctl.conf
# Masquerade outgoing traffic
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
# Allow return traffic
iptables -A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# Forward everything
iptables -A FORWARD -j ACCEPT
docker run -d --privileged --restart=always --net=host --name vtun-client \
netbyte/vtun -s server-addr:3001 -c 172.16.0.10/24 -k 123456
docker run -d --privileged --restart=always --net=host --name vtun-client \
netbyte/vtun -s server-addr:3001 -c 172.16.0.10/24 -k 123456 -g
docker run -d --privileged --restart=always --net=host --name vtun-server \
netbyte/vtun -S -l :3001 -c 172.16.0.1/24 -k 123456
Thanks JetBrains for providing licenses.