
Tengo 2 servidores Ubuntu con configuración Wireguard. Un servidor actúa como intermediario. por lo que el tráfico de los clientes se enruta al servidor intermedio y el servidor intermedio los enruta al otro servidor (aquí lo llamo servidor 1). en mi caso, el tráfico se enruta completamente desde el cliente al servidor intermedio y luego al servidor 1. pero no se enruta de regreso al servidor intermedio, por lo que no hay Internet cuando Wireguard está conectado. la wg show
salida en el servidor 1 es así:
interface: wg0
public key: Public-Key
private key: (hidden)
listening port: 51880
peer: Public_key
endpoint: [middle server ip:port]
allowed ips: 10.0.0.0/24
latest handshake: 1 minute, 21 seconds ago
transfer: 7.34 KiB received, 372 B sent
persistent keepalive: every 25 seconds
Y aquí están mis servidores y la configuración del cliente:
configuración del servidor 1:
[Interface]
PrivateKey = Private-Key
Address = 10.0.0.1/24
ListenPort = 51880
MTU = 1500
PostUp = iptables -A FORWARD -i eth0 -o wg0 -j ACCEPT; iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ufw route allow in on wg0 out on eth0; ufw route allow in on eth0 out on wg0; ufw allow proto udp from any to any port 51880
PostDown = iptables -D FORWARD -i eth0 -o wg0 -j ACCEPT; iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ufw route delete allow in on wg0 out on eth0; ufw route delete allow in on eth0 out on wg0; ufw delete allow proto udp from any to any port 51880
[Peer]
PublicKey = middle server Public-Key
AllowedIPs = 10.0.0.2/24
EndPoint = [middle server ip:port]
PersistentKeepalive = 25
Configuración del servidor intermedio:
[Interface]
PrivateKey = Private-Key
Address = 10.0.0.2/24
ListenPort = 52890
Table = 123
MTU = 1500
PreUp = ip rule add iif wg0 table 123 priority 456
PostUp = iptables -A FORWARD -i eth0 -o wg0 -j ACCEPT; iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ufw route allow in on wg0 out on eth0; ufw route allow in on eth0 out on wg0; ufw allow proto udp from any to any port 52890
PostDown = iptables -D FORWARD -i eth0 -o wg0 -j ACCEPT; iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ufw route delete allow in on wg0 out on eth0; ufw route delete allow in on eth0 out on wg0; ufw delete allow proto udp from any to any port 52890; ip rule del iif wg0 table 123 priority 456
[Peer]
PublicKey = Server 1 Public-Key
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
[Peer]
PublicKey = Clint Public-key
AllowedIPs = 10.0.0.102/32
Configuración del cliente (cliente de Windows):
[Interface]
PrivateKey = Private-Key
Address = 10.0.0.102/32
DNS = 1.1.1.1, 1.0.0.1
MTU = 1480
[Peer]
PublicKey = middle server Public-Key
AllowedIPs = 0.0.0.0/1, 128.0.0.0/1
Endpoint = [Middle server ip:port]
PersistentKeepalive = 25
Intenté cambiar el puerto y las direcciones pero no funcionó.