¡Esta es una revisión vieja del documento!
Wireguard
Solución para crear túneles VPN. Más segura, moderna y eficiente que otras soluciones de código abierto como OpenVPN.
Servidor
Una forma sencilla de instalarlo es mediante Docker con la imagen de LinuxServer.io. Ejemplo del docker-compose.yml:
version: "2.1" services: wireguard: image: ghcr.io/linuxserver/wireguard container_name: wireguard cap_add: - NET_ADMIN - SYS_MODULE environment: - PUID=1000 - PGID=1000 - TZ=Europe/Madrid - SERVERURL=tempwin.net #optional - SERVERPORT=51820 #optional - PEERS=1 #optional - PEERDNS=auto #optional - INTERNAL_SUBNET=10.13.13.0 #optional - ALLOWEDIPS=0.0.0.0/0 #optional volumes: - ./config:/config - /lib/modules:/lib/modules ports: - 51820:51820/udp sysctls: - net.ipv4.conf.all.src_valid_mark=1 restart: unless-stopped
PEERS: indica el número de clientes para los que Wireguard creará configuraciones. Puede ser numérico o una lista de nombres (myPC, myPhone, myTablet…)INTERNAL_SUBNET: subred que usarán los clientes conectados a la VPN.SERVERURL: IP o dominio en el que está Wireguard.
Una vez arrancado, vamos a consultar los logs para poder ver el código QR que tendrá que escanear el primer cliente de esa VPN:
docker-compose logs -f --tail=10
Ejemplo de salida:
(...) wireguard | PEER 1 QR code: wireguard | █████████████████████████████████████████████████████████████████ wireguard | █████████████████████████████████████████████████████████████████ wireguard | ████ ▄▄▄▄▄ █▄█ ▀ ▀▀█▄ ▀▀█ ▄ ▀▄▄█ ▄▀▀▀▀ ▀▀█▀ ▀▀█▀▄ ██ ▄▄▄▄▄ ████ wireguard | ████ █ █ █ █▀██▀█▀▄█▀▀▄▄▄▄▀█ █▄▀▄▀▄▄█ ▀▄▀▄▄▄█▀▄▀▄ ██ █ █ ████ wireguard | ████ █▄▄▄█ █▄██▄▀█▀▄▄▄▀█▄▀▀█ ▄ ▄▄▄ ▄ ▀▄█ ▄▀██ █ ▀▄██ █▄▄▄█ ████ wireguard | ████▄▄▄▄▄▄▄█▄█ ▀ █▄▀ ▀ █ ▀▄█ █ █▄█ █▄█▄█ ▀ █ ▀ █ ▀▄▀▄█▄▄▄▄▄▄▄████ wireguard | ████▄▄ █▀▄█▄ ███▀▀██▄▀▄█▄▄▀ ▄▄ ▄▄ ▄█▀▄█▀ █▄▄▀ ▄█▀▄ ▀ ██▄▄▄▀ ████ wireguard | ████ ▄ ▀▀██▀▄▄█▀ ▀ █ ▄▀▀▄ ▀▄██ ▀██▀█▀ ▄███▄▄▄████▄▄▄▄ ▀██▀▄ ▄████ wireguard | ████ ▀ ▄▄ ▄▀▄ ▀▀ ▄ █▄▀ █ ▄ █ █▄██▄▄ █▀▀▀ █▄▀ ▄▀▄ ▀█▀▀▄█▀████ wireguard | █████▀ ▄ ▄▄▄▄▀██▀██▀▄█▄ ██▄ ▄██ ▀▄▄▄██▀█▀ ▀▀█▄ █▄ ▀ ▀ █████ wireguard | █████ ████▄ ▀▄▀█▀ ▀▀▀█▄ █▀▄ ▄▀▀ ██▄▀ ██▄▄▄█ █▀ ▀ ▀▄▄▄ █▄ █████ wireguard | ████▀ ██▄▀▄█ █▄▀█▄▄▄▄▀▄██ █ ▀ █▀▀▄██ ▀▄ ▄▄█ ▀█▀▀▄▄▀ █▀██▄▀████ wireguard | ████▀ ▄ ▄▀▀▄ ▀█▄ ▄ █ ▀▄▄▄▀██▄ █▀█▀█▄█▀ ▄▄▄ ▀▀█ ▄█ ▄ ▄ ▀▀█████ wireguard | ████▀▄▀ ▄▄▄█▄█▄▄█ ▄▀▀██▀█ ██ ▄▄▀▀▄▄ ▀▄█▀ ▄█▄▄▄ █▄█▀██ █▄▄████ wireguard | █████▄▄ ▄▄█▄▄▀ ▀▄▄ ▄ ▄ ▀ █ ██▀▄▄██▄▄█▄ ▀▀▀▄▄██▄▄▄▄▀▀▀▀▀▀▄█████ wireguard | █████▀▄ ▄▄▄ ▀▄▄▄▄▀▄▀▀▀██ ▀█▄ ▄▄▄ █ ▀▄▄██ ▄█ ▄█ █▀ ▄▄▄ ▀ █████ wireguard | █████▀▄ █▄█ ▀▀ ▄▄ ▀ ██ ▄ ██▀ █▄█ ▄▀ █▀█ █▄█▄▄ ▀ █▄█ ▄▄█████ wireguard | ████ ▄▄█▄ ▄ ▄█▀ █▀█ █▄█ ▀▀▀▄▄ ▄ ▄▀▄▀█▄▄█ █▄ ▀▀▄▄▄ ▄▄▄██▄█████ wireguard | ████ █▀▄█ ▄█ ▄███ ▀▄█▄█▀██ ▄ █▀▄██▀▄█▀▄▄█▀▄█▄ ▀▄▀▄██▄ ▀▄█▄▀▄▀████ wireguard | ██████▄█ ▄▀▄█▀ █▀▀▄██▀▄▄█▀█▄ ▄ ▀▄██ ▀ █ █ ▀▄ ▀ ▄ ▀ █▄ ████ wireguard | ████▀▄▀█▄█▄▀█ ▀ ▀ ▀▀▄▄▀ ▀█ █ ▀▄▄ ▀ ▄▀▄▄ ██▄█▄██ ▄▄▀▄▄█ ▀████ wireguard | ████ ▀▀▀ ▄▀▄▀▄▄▄███▀▄▄██ ▀▄▀▀█▀▄▀▄ ▀▄ ██▄▄ █ ▀▄█ ▄▄▀▀▄ ▀▄█████ wireguard | ████▀▀▄▀█▄▄ ▄▄██ █▀ █▀█▄▄█▀█▄█▀▀▄▀▀▄█▀▄██▄ █ █▀▄▄▀▄ █▄▀ █ ████ wireguard | ████▄▀ ▀▀▄█▀ ▄ ███▄█ ▀▄ █▀ █ ██ █▀▄▄▀▄ ▄█ █▀█▄▀▄█ ▄█▄▄███▀████ wireguard | ████ ▀ ▄▀█ ▀ ▄▄ ▄▄▄ ▄█▄█ ▄█▀▄▄█▀██▄▄▀ █▄▄▄▀███▄▀▄██▄▄ ▀████ wireguard | ████ ▀ ▀▀▄▄█▄▀▀█▄▄ █▄█▀█ █▀▀▀▀██▀██▀ ▄ ▄▀██ █ ▀ ▀ ▀▄▄▀▀▄▄▄▄████ wireguard | ██████████▄█ ▀▄▄▄ █▄█ ▄ ▄ ▀█▄█ ▄▀▀▄█▄▄▀▀ ▀▄▄▄█▀▄█ ▄▄▄ ▄█ █████ wireguard | ████ ▄▄▄▄▄ ██▄█▄▄▄▀█▄█▄█▄▀▄▄▀▄ █▄█ █ ▄▀▄▀▄▄▄█▀ ▀▄▄ █▄█ ▀▄▀████ wireguard | ████ █ █ █▀ ▄▀▄▄█▄▀▄██ ▄▄███ ▄▄▄ ▀ █ ▄██▀▀▄ ▄ ▀▄ ▄▄ █████ wireguard | ████ █▄▄▄█ █ ▄ ██ █▀█▀█ ▀▀ ▄ ▄▀▄ █ ▄▀▄▄▀ ▄▄█▀▀███ ██▄▄█▀████ wireguard | ████▄▄▄▄▄▄▄█▄▄██▄▄█▄█▄██▄█▄█▄██████▄██████▄▄▄██▄█▄▄▄▄▄▄▄▄▄▄██████ wireguard | █████████████████████████████████████████████████████████████████ wireguard | █████████████████████████████████████████████████████████████████ wireguard | [cont-init.d] 30-config: exited 0. wireguard | [cont-init.d] 99-custom-scripts: executing... wireguard | [custom-init] no custom files found exiting... wireguard | [cont-init.d] 99-custom-scripts: exited 0. wireguard | [cont-init.d] done. wireguard | [services.d] starting services wireguard | [services.d] done. (...)
Variables SERVERURL, SERVERPORT, INTERNAL_SUBNET and PEERDNS are optional variables used for server mode. Any changes to these environment variables will trigger regeneration of server and peer confs. Peer/client confs will be recreated with existing private/public keys. Delete the peer folders for the keys to be recreated along with the confs.
Si queremos volver a crear las claves y configuraciones, basta con eliminar los directorios peer, dentro de config.
Para añadir más clientes/peers, aumentamos el valor de la variable de entorno PEERS y recreamos el contenedor.
Si queremos volver a ver los códigos QR de los clientes/peers activos:
docker exec -it wireguard /app/show-peer 1 4 5
También sería válido:
docker exec -it wireguard /app/show-peer myPC myPhone myTablet
Los códigos QR también se almacenan en el directorio config como imágenes PNG
Cliente
- Cliente Android en Google Play o F-Droid
