安装 wireguard 用户态工具
dnf install -y wireguard-tools加载 wireguard
modprobe wireguard验证
lsmod | grep wireguard
wg --version防火墙配置
firewall-cmd --permanent --add-port=51820/udp
firewall-cmd --reload配置服务端
生成密钥
wg genkey | tee privatekey | wg pubkey > publickey配置 wireguard
chmod 700 /etc/wireguardvim /etc/wireguard/wg0.conf[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <服务端私钥>
[Peer]
PublicKey = <客户端公钥>
AllowedIPs = 10.0.0.2/32开放端口
firewall-cmd --permanent --add-port=51820/udp
firewall-cmd --reload配置客户端
[Interface]
Address = 10.0.0.2/24
PrivateKey = <客户端私钥>
DNS = 1.1.1.1
[Peer]
PublicKey = <服务端公钥>
Endpoint = <服务器公网IP>:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25启动 wireguard
systemctl enable wg-quick@wg0
systemctl status wg-quick@wg0
评论