:::: MENU ::::

Usar Wireguard con UFW

Configurar UFW para que permita fordwards

En el archivo /etc/ufw/before.rules añadir al principio:

# Reglas para NAT
*nat
:POSTROUTING ACCEPT [0:0]
# Reenviar tráfico de WireGuard a través de enX0 (buscar enX0 en ip addr)
-A POSTROUTING -s 10.0.0.0/24 -o enX0 -j MASQUERADE
COMMIT

Activar el forwarding en /etc/ufw/sysctl.conf

net/ipv4/ip_forward=1

Configurar Wireguard

Con esto hacemos que se permita el tráfico fluir entre el interfaz de Wireguard y el de Internet solo cuando Wireguard está activo. En /etc/wireguard/wg0.conf

[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <TU_LLAVE_PRIVADA>

# Reglas de enrutamiento dinámico para enX0
PostUp = ufw route allow in on wg0 out on enX0
PostDown = ufw route delete allow in on wg0 out on enX0



Hey! Qué opinas sobre el artículo?