Ubuntu下WireGuard的常用操作

Wireguard的配置文件位置:

/etc/wireguard/wg0.conf

不中断服务更新配置文件:

wg syncconf wg0<(wg-quick strip wg0)

重启服务:

systemctl restart wg-quick@wg0.service

显示状态:

wg show

生成密钥对:

wg genkey | tee /etc/wireguard/privatekey | wg pubkey | tee /etc/wireguard/publickey

启动与停止某端口:

wg-quick up wg0
wg-quick down wg0

初次安装需要开启内核的转发功能:

echo 1 > /proc/sys/net/ipv4/ip_forward

echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf

sysctl -p