To pass wireguard's traffic through a TCP tunnel by using udp2raw
For Arch linux, install udp2raw by pacman:
pacman -S udp2raw
For Debian or Ubuntu, you can use a binary release from: https://github.com/wangyu-/udp2raw/releases
Then, install it under /sbin directory. For example, on a x86_64 system:
wget https://github.com/wangyu-/udp2raw/releases/download/20200818.0/udp2raw_binaries.tar.gz
tar xzvf udp2raw_binaries.tar.gz
sudo mv udp2raw_amd64 /sbin
- Replace private and public keys in configuration files
- Replace password in udp2raw command in both server's and client's configuration file
- Change
YOUR-SERVER-IPin client's config file (in udp2raw command) to your server IP address - On both server and client, copy corresponding config file to
/etc/wireguard/wg0 - Start wireguard on both server and client:
sudo systemctl start wg-quick@wg0 - Check connectivity by performing a ping command from client:
ping 10.8.0.1
- Please note that based on the configuration provided, by udp2raw command, port
4096of your server will be exposed to the world. Of course, you can change it to another port number. - If it doesn't work, remove
PreUpandPostdownlines from both configs and runudp2rawcommands in command-line with a--log-leveloption to see if TCP tunnel can be successfully established.
In 80% case, it means your
-k/--keyor--cipher-mode--auth-modedoesn't match on client and server side. In this case, it's an easy fix.In 5% case, it means your internet connection doesn't allow the packet constructed by raw socket to passthrough transparently (It might be because of your client's ISP or virtual machine's network adapter mode; or something related to your server's network infrastructure). In this case, you can barely do anything other than changing the ISP or server provider.