сервер # 1. Белый ip 100.0.0.1, wireguard ip 10.0.0.1
сервер # 2. Белый ip 200.0.0.1, wireguard ip 10.0.0.2
конфиг wg0.conf на сервере #1:
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = < privateKey сервера #1 >
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; iptables -A FORWARD -o %i -j ACCEPT
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; iptables -D FORWARD -o %i -j ACCEPT
[Peer]
PublicKey = < publicKey сервера #2 >
AllowedIPs = 10.0.0.2/32
конфиг wg0.conf на сервере #2:
[Interface]
Address = 10.0.0.2/32
PrivateKey = <privateKey сервера # 2>
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; iptables -A FORWARD -o %i -j ACCEPT
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; iptables -D FORWARD -o %i -j ACCEPT
[Peer]
PublicKey = <publicKey сервера # 1>
AllowedIPs = 10.0.0.0/24
Endpoint = 100.0.0.1:51820
PersistentKeepalive = 10