< Regresar Estás aquí: KB Seguridad Configuración de VPN con WireGuard (Servidor y Cliente en Linux y Windows) Imprimir Created Onabril 13, 2026 Last Updated Onabril 13, 2026 bykbs 📌 ObjetivoImplementar una red privada virtual (VPN) utilizando WireGuard, permitiendo comunicación segura entre clientes y servidor en entornos mixtos Linux y Windows. 🧩 Arquitectura [ Cliente (Windows/Linux) ] <—> [ Servidor WireGuard (Linux recomendado) ] Comunicación cifrada mediante claves públicas/privadasUso de UDP (por defecto puerto 51820)Red privada virtual (ej: 10.0.0.0/24) 🔐 Conceptos clave ConceptoDescripciónPrivate KeyClave privada del nodoPublic KeyClave pública derivadaEndpointIP:Puerto del servidorAllowedIPsRedes permitidasInterfaceConfiguración localPeerNodo remoto 🖥️ 1. Configuración del Servidor (Linux) Recomendado: Ubuntu 20.04+ 📦 Instalación sudo apt updatesudo apt install wireguard -y 🔑 Generación de claves mkdir -p /etc/wireguardcd /etc/wireguardwg genkey | tee privatekey | wg pubkey > publickey ⚙️ Configuración nano /etc/wireguard/wg0.conf 🌐 Habilitar forwarding echo “net.ipv4.ip_forward=1” | sudo tee -a /etc/sysctl.confsudo sysctl -p ▶️ Levantar servicio sudo wg-quick up wg0sudo systemctl enable wg-quick@wg0 🔍 Ver estado sudo wg show 💻 2. Configuración Cliente Linux 📦 Instalación sudo apt updatesudo apt install wireguard -y 🔑 Generación de claves mkdir -p /etc/wireguardcd /etc/wireguardwg genkey | tee privatekey | wg pubkey > publickey ⚙️ Configuración nano /etc/wireguard/wg0.conf EJEMPLO: [Interface] Address = 10.0.0.2/24 PrivateKey = "CLIENT_PRIVATE_KEY" [Peer] PublicKey = "SERVER_PUBLIC_KEY" Endpoint = "SERVER_IP:51820" AllowedIPs = 0.0.0.0/0 PersistentKeepalive = 25 ▶️ Levantar servicio sudo wg-quick up wg0sudo systemctl enable wg-quick@wg0 🪟 3. Configuración Cliente Windows 📥 Instalación Descargar desde: 👉 https://www.wireguard.com/install/ Aplicación: WireGuard for Windows ⚙️ Crear túnel Abrir WireGuard Click en “Add Tunnel” → “Add empty tunnel” Se generan claves automáticamente 📝 Configuración EJEMPLO:[Interface]PrivateKey = <CLIENT_PRIVATE_KEY>Address = 10.0.0.3/24DNS = 8.8.8.8[Peer]PublicKey = <SERVER_PUBLIC_KEY>Endpoint = <SERVER_IP>:51820AllowedIPs = 0.0.0.0/0PersistentKeepalive = 25 ▶️ Activar Click en Activate 🔗 4. Agregar clientes al servidor nano /etc/wireguard/wg0.conf [Peer]PublicKey = <CLIENT_PUBLIC_KEY>AllowedIPs = 10.0.0.2/32 # sudo wg syncconf wg0 <(wg-quick strip wg0) 🔥 5. Firewall y puertos Abrir puerto en servidor: sudo ufw allow 51820/udp 🧪 6. Pruebas Desde el cliente:ping 10.0.0.1