Instalar y configurar WireGuard como cliente en Raspberry Pi
Actualizar repositorios
sudo apt update
Instalar wireguard y resolvconf que es requeridos para iniciar el servicio.
sudo apt install wireguard
sudo apt install resolvconf
Crear el archivo de configuración y agregar la configuraciones de nuestro cliente proporcionada por el servidor.
sudo nano /etc/wireguard/wg0.conf
El contenido del documento debe ser algo como lo siguiente:
[Interface]
Address = 10.10.20.8
PrivateKey = EPF7JZkZ5F42sYx0E0JQemPVDGvgTWVQDUhNaCy1MWE=
ListenPort = 51820
DNS = 10.10.20.1[Peer]
PublicKey = IGW6JFEEuW2EvloLnvS3giShqmpfwV6i0MwLKIfdNB4=
PresharedKey = emvYCAYvOP9zjTneyBc0tApHtSRgtJAa/w36eleYunM=
Endpoint = vpn.yourdomain.com:51820
AllowedIPs = 10.10.20.0/24
Crear el servicio para el inicio automático de la vpn al iniciar el sistema y recargar controlador(daemon) de servicios.
sudo systemctl enable wg-quick@wg0.service
sudo systemctl daemon-reload
Iniciar el servicio de la vpn
sudo systemctl start wg-quick@wg0
Vemos las conexiones de red y deberíamos tener iniciada nuestra vpn.
sudo ip address
...
4: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000
link/none
inet 10.10.20.8/32 scope global wg0
valid_lft forever preferred_lft forever
Hacemos ping al servidor y debería responder si todo esta funcionando correctamente
ping 10.10.20.1
PING 10.10.20.1 (10.10.20.1) 56(84) bytes of data.
64 bytes from 10.10.20.1: icmp_seq=1 ttl=64 time=9.78 ms
64 bytes from 10.10.20.1: icmp_seq=2 ttl=64 time=1.55 ms
64 bytes from 10.10.20.1: icmp_seq=3 ttl=64 time=1.50 ms
....
Listo! Ahora nuestra Raspberry está en la vpn.