WireGuard设置多用户客户端

648

前面各种折腾的内容都记录在《》一文中了,这里记录一下具体配置信息。

其实相对WireGuard严格来讲并没有Server/Client这一说,它是用对称配置,你中有我,我中有你,但是笔者是用有固定外网IP的作为“Server”端,其它通过这台机器科学上网的为“Client”端。

记录一下WireGuard多客户端配置的方法:

Server:


[Interface]
Address = 192.168.2.1/24
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
ListenPort = 51820 #设置端口
PrivateKey = <!--Server PrivateKey-->

[Peer]
PublicKey = <!--Client1 PublicKey-->
AllowedIPs = 192.168.2.3/32

[Peer]
PublicKey = <!--Client2 PrivateKey-->
AllowedIPs = 192.168.2.5/32

Client

[Interface]
Address = 192.168.2.3/24
DNS = 8.8.8.8
PrivateKey = <!--Client1 PrivateKey-->
[Peer]
AllowedIPs = 0.0.0.0/0
Endpoint = <!--Server Public IP-->:51820
PublicKey = <!--Server PrivateKey-->

Post Comment