¡Esta es una revisión vieja del documento!
Tabla de Contenidos
WireGuard – Túnel VPN entre el VPS y la red local
El VPS mantiene un túnel VPN activo con varias Raspberry Pi mediante WireGuard, lo que permite enrutar tráfico hacia los servicios internos incluso cuando están detrás de NAT o sin IP pública.
Dirección e interfaz
- Interfaz: wg0
- Red virtual: 10.100.100.0/24
- El VPS tiene la IP 10.100.100.1 en esta red
Comandos útiles
Ver el estado del túnel
systemctl status wg-quick@wg0
* Si ves Active: active (exited) o active (running) → está levantado
* Si ves failed o inactive → no está funcionando
Arrancar manualmente
sudo systemctl start wg-quick@wg0
Detener el túnel
sudo systemctl stop wg-quick@wg0
Habilitar al arranque automático
sudo systemctl enable wg-quick@wg0
Ver tráfico y peers activos
sudo wg show
Configuración
El archivo principal está en:
/etc/wireguard/wg0.conf
sudo nano /etc/wireguard/wg0.conf
Ejemplo básico de configuración (lado del VPS):
[Interface]
Address = 10.100.100.1/24
ListenPort = 51820
PrivateKey = YHMB6QhmK4bUb4UyTiNjzEKQ35uB7qbvQwnbRFOblkM=
# CloudPanel
[Peer]
PublicKey = aGf09I65s++rnwozAUiOBvykBOWieaJexBXPpQM4VE8=
AllowedIPs = 10.100.100.2/32
PersistentKeepalive = 25
*Cada Raspberry tiene su propia sección [Peer] con su IP virtual e IP real configurada desde el cliente.*
Key's
Para enlazar equipos dentro de la red wireguard, existen dos keys:
- IP PrivateKey del VPS: YHMB6QhmK4bUb4UyTiNjzEKQ35uB7qbvQwnbRFOblkM=
- IP PublicKey del VPS: Y09ujDcdLskh+L7zTOHNluPRwb0fYuUMskvyKHKMag0=
Servicios accedidos por VPN desde el VPS
Estos son los equipoc conectados al servidor VPS:
- Raspberry Pi 5 - 8 Gb Ram: CloudPanel (dominios): 10.100.100.2
- Raspberry Pi 5 - 8 Gb Ram: iRedMail (correo): 10.100.100.3
- Raspberry Pi 4 - 8 Gb Ram: OpenMediaVault (Nas): 10.100.100.4
- Raspberry Pi 4 - 2 Gb Ram: Seguridad (Pi-Hole): 10.100.100.5
- Raspberry Pi 3 - 1 Gb Ram: Octoprint (Printer 3D): 10.100.100.6
- Raspberry Pi 5 - 8 Gb Ram: PhotoPrism (Fotografías): 10.100.100.7
- Raspberry Pi 5 - 8 Gb Ram: Servicios (Utilidades): 10.100.100.8
Notas:
- El puerto 51820 debe estar abierto en el firewall del VPS. Esta abierto por iptables
- La red WireGuard permite enrutar tráfico SMTP, HTTP, SSH, etc.
