少女祈祷中...
NEKO
知识库

rockylinux 安装 wireguard

安装 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/wireguard

vim /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

评论