Skip to content

Настройка и установка VPN Wireguard

Создание и регистрация

bash
sudo apt update && sudo apt install wireguard resolvconf -y

Generate keys

bash
wg genkey | sudo tee /etc/wireguard/private-server.key
sudo cat /etc/wireguard/private-server.key | wg pubkey | sudo tee /etc/wireguard/public-server.key

Configure

text
[Interface]
Address = 10.0.0.1/24
PrivateKey = <сервер_private_key>
ListenPort = 51820
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -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

[Peer]
PublicKey = <клиент_public_key>
AllowedIPs = 10.0.0.2/32

IP Forward

bash
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Update

bash
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0

Client

bash
[Interface]
PrivateKey = <клиент_private_key>
Address = 10.0.0.2/32
DNS = 8.8.8.8

[Peer]
PublicKey = <сервер_public_key>
Endpoint = <SERVER_IP>:51820
AllowedIPs = $(cat /etc/wireguard/youtube_ips.txt)
PersistentKeepalive = 25