Certainly! Here's the translated content with preserved formatting:
Catalog
- Selection
- Implementation
- Practical Testing
WireGuard Over VLESS - A More Stable Triple-layer Tunnel
WireGuard, as a more modern and advanced VPN implementation, is more efficient and easier to set up compared to traditional IPSec, OpenVPN, etc. It has been integrated into the Linux kernel, making installation and use more convenient. It is increasingly used in cross-border tunnels, such as bridging domestic and foreign machines with WireGuard to create a pseudo IPLC dedicated line. With this additional VPN protocol layer, running various proxy protocols like Socks, SS, etc., in the pseudo-dedicated line gains an extra layer of protection, avoiding being exposed.
However, WireGuard uses UDP and wasn't designed to evade censorship, similar to proxy protocols that are susceptible to identification, interference, and blocking. In addition, UDP can be unstable during peak hours, with fluctuating speeds. Therefore, it's necessary to further encapsulate WireGuard with another tunnel.
Selection
Considering the protocols in the V2Ray series, VLESS was ultimately chosen. Currently, the mainstream method to evade censorship relies on the cryptographic strength of TLS to ensure security while disguising traffic as HTTPS for obfuscation. Therefore, VMESS/VLESS protocols are comparatively better. Since the VMESS protocol comes with encryption that overlaps with WireGuard's encryption, it is a performance waste, making non-encrypted VLESS more suitable.
VLESS is still on the rise and offers better scalability. Regardless of how obfuscation strategies develop, adjustments can be made at the transmission level by modifying streamSettings, without changing the tunnel protocol.
Implementation
- Domestic Machine A, Public IP 1.3.5.7, Internal IP 10.10.0.1
- Foreign Machine B, Public IP 2.4.6.8, Internal IP 10.10.20.1
VLESS Configuration
For simplicity, we use the VLESS TCP mode directly.
On foreign machine B, set up VLESS inbound to receive VLESS TCP traffic on port 52220 of 2.4.6.8.
{
"log": {
"loglevel": "debug"
},
"dns": {
"servers": [
"1.1.1.1",
"8.8.8.8",
"8.8.4.4"
]
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 52220,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "c71c5890-56dd-4f32-bb99-3070ec2f20fa"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp"
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIP"
},
"tag": "free"
}
],
"routing": {
"rules": []
}
}
On domestic machine A, setup VLESS outbound, using the dokodemo-door protocol for inbound, add a UDP forwarding, listen to UDP traffic on port 10000 on A, and forward this traffic via VLESS outbound to 127.0.0.1:10000 on the server side.
{
"log": {
"loglevel": "debug"
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 10000,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1",
"port": 10000,
"network": "udp"
},
"tag": "wg"
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
},
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "2.4.6.8",
"port": 52220,
"users": [
{
"id": "c71c5890-56dd-4f32-bb99-3070ec2f20fa",
"encryption": "none"
}
]
}
]
},
"streamSettings": {
"network": "tcp"
},
"tag": "vless-tunnel"
}
],
"routing": {
"rules": [
{
"type": "field",
"inboundTag": [
"wg"
],
"outboundTag": "vless-tunnel"
}
]
}
}
Thus, we can forward UDP traffic directed to 127.0.0.1:10000 on domestic machine A through the VLESS tunnel to 127.0.0.1:10000 on foreign machine B.
WireGuard Configuration
On domestic machine A, add an interface, set Endpoint to 127.0.0.1:10000, flow into VLESS's inbound.
[Interface]
Address = 10.10.0.1
DNS = 1.1.1.1
PrivateKey = PrivateKey
ListenPort = 51820
MTU = 1420
[Peer]
PublicKey = PublicKeyB
AllowedIPs = 10.10.20.1
Endpoint = 127.0.0.1:10000
PersistentKeepalive = 20
On foreign machine B, also add an Interface, listening on port 10000, to receive traffic forwarded by VLESS.
[Interface]
Address = 10.10.20.1
ListenPort = 10000
PrivateKey = PrivateKey
MTU = 1420
[Peer]
PublicKey = PublicKeyA
AllowedIPs = 10.10.0.1
With the configuration complete, start VLESS and WireGuard on both machines to establish connectivity.
To change transmission methods, modify the streamSettings configuration of inbound and outbound as needed. Refer to Xray examples for details.
Practical Testing
Test during peak hours using domestic Shanghai CN2 NAT and foreign AWS HK EC2.
It can be seen that adding the TCP tunnel significantly improves the interference state of WireGuard's native UDP, with ping changes not being obvious, suggesting that the UDP hole-punching connection was successfully established with minimal impact on ping.
Comments and Discussion
- Han Han: Reply - "The method is impressive."
- Dodo Dodo: Reply - "It can be more elegant because both TLS and WireGuard have encryption. Consider using GRE OVER GUE for higher efficiency."
- 40huo: Reply to Dodo Dodo - "Not using TLS to avoid double encryption. Not using GRE because we wanted to use WireGuard."
- Huazai: Reply - "This idea is indeed good. WireGuard's performance is considerably better than other VPNs."
- Tom: Reply - "Is it possible to monitor 0.0.0.0 instead of 'listen': '127.0.0.1' for inbound on the domestic NAT machine?"
Further technical discussions continue in the comment section.
The formatted content maintains the structure and technical details of the original text, ensuring clarity and ease of understanding.