Dica importante no caso de configurar o servidor e não navegar as vezes é necessário reiniciar a estação do cliente, e aguardar alguns horas !
No meu caso especifico tinha iniciado com centos 7 e só consegui funcionalidade no ubuntu 20.04
Entretanto o site do wireguard indica varios OS e como instalar verifiquei a solução mais simples foi a solução !
sudo apt install wireguard
sudo ufw allow 61951/udp
sudo nano /etc/sysctl.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forward=1
sudo sysctl -p
Use este comando para gerar chaves e tornar uma privada acessível apenas ao usuário root por motivos de segurança.
wg genkey | sudo tee /etc/wireguard/server_private.key | wg pubkey | sudo tee /etc/wireguard/server_public.key
sudo cat /etc/wireguard/server_private.key
cat /etc/wireguard/server_public.key
sudo nano /etc/wireguard/wg0.conf
[Interface] PrivateKey = oCH7Z0g+ieQ99KkkR1E5EO22Evs5q75F+ES4O4Oc93E= # The server_private.key value. Address = 10.5.5.1/24 # Internal IP address of the VPN server. ListenPort = 61951 # Previously, we opened this port to listen for incoming connections in the firewall.
Change "enp0s5" to the name of your network interface in the following two settings. This commands configures iptables for WireGuard.
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
[Peer] PublicKey = gsgfB29uYjpuFTCjC1+vHr9M7++MHJcG6Eg4rtuTu34= # client_public.key value. AllowedIPs = 10.5.5.2/32 # Internal IP address of the VPN client.
sudo systemctl start wg-quick@wg0
sudo systemctl enable wg-quick@wg0
sudo apt install resolvconf
sudo nano /etc/wireguard/wg0.conf
[Interface] PrivateKey = eLI6PoQf3xhLHu+wlIIME5ullpxxp8U+sYMKHGcv2VI= # The client_private.key value. Address = 10.5.5.2/24 # IP address of the client's wg0 interface. DNS = 8.8.8.8
[Peer] PublicKey = tsGQ8spwOQhpJb4BbhZtunLZEJCcPxUBIaQUpniQ+z4= # The server_public.key value. AllowedIPs = 0.0.0.0/0 # Traffic for these addresses will be routed through the VPN tunnel. In this example, all addresses are selected. Endpoint = 82.213.236.27:61951 # Public IP address of our VPN server and port number (ListenPort in the server configuration). PersistentKeepalive = 25
sudo wg-quick up wg0
wg
interface: wg0 public key: gsgfB29uYjpuFTCjC1+vHr9M7++MHJcG6Eg4rtuTu34= private key: (hidden) listening port: 58208
peer: tsGQ8spwOQhpJb4BbhZtunLZEJCcPxUBIaQUpniQ+z4= endpoint: 82.213.236.27:61951 allowed ips: 0.0.0.0/0 ...
Reference: https://serverspace.io/pt/support/help/set-up-wireguard-vpn-server-on-ubuntu/