Wiregurd 覆盖 wg0.conf

Gil*_*tes 8 debian wireguard

我已在 Debian Buster 上成功安装 Wireguard。现在我想稍后配置 IPv6。我已经这么做了。[Peer]但-Section内的设置wg0.conf似乎并不持久。

systemctl stop wg-quick@wg0.service
nano /etc/wireguard/wg0.conf
Run Code Online (Sandbox Code Playgroud)

结果:

[Peer]
PublicKey = xxxxx
AllowedIPs = 10.200.200.2/32, xxx:xxxx:xx:xxx:100::2/72
Run Code Online (Sandbox Code Playgroud)

保存并重新启动服务后,systemctl start wg-quick@wg0.service看起来wg0.conf不错。

当我再次重新启动虚拟机或服务时,所有其他设置都会丢失。

[Peer]
PublicKey = xxxxx
AllowedIPs = 10.200.200.2/32
Run Code Online (Sandbox Code Playgroud)

任何想法?

这就是我wg0.conf应该的样子

[Interface]
Address = 10.200.200.1/24
Address = xxxx:xxx:xx:xxx::1/72
DNS = 10.200.200.1
SaveConfig = true
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROU$
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTR$
ListenPort = 51820
PrivateKey = xxx

[Peer]
PublicKey = xxx
AllowedIPs = 10.200.200.2/32, xxx:xxxx:xx:xxx:100::2/72

[Peer]
PublicKey = xxx
AllowedIPs = 10.200.200.3/32, xxx:xxxx:xx:xxx:100::3/72

[Peer]
PublicKey = xxx
AllowedIPs = 10.200.200.4/32, xxx:xxxx:xx:xxx:100::4/72
Run Code Online (Sandbox Code Playgroud)

Gil*_*tes 9

解决了问题。魔术:wg-quick down wg0在编辑文件之前始终停止界面wg0.conf。下次启动后将systemctl stop wg-quick@wg0.service 覆盖该文件。wg0.conf