Debian

Wiregurard 覆蓋 wg0.conf

  • July 4, 2020

我已經在 Debian Buster 上成功安裝了 Wireguard。現在我想在之後配置 IPv6。我已經做到了。但是[Peer]-Section 中的設置wg0.conf似乎並不持久。

systemctl stop wg-quick@wg0.service
nano /etc/wireguard/wg0.conf

結果:

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

保存並重新啟動服務後systemctl start wg-quick@wg0.servicewg0.conf看起來很好。

當我再次重新啟動 VM 或服務時,我的所有其他設置都將失去。

[Peer]
PublicKey = xxxxx
AllowedIPs = 10.200.200.2/32

任何的想法?

這就是我的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

解決了這個問題。魔術:wg-quick down wg0在編輯 wg0.conf 文件之前總是停止界面。下次啟動後將systemctl stop wg-quick@wg0.service 覆蓋文件。wg0.conf

引用自:https://serverfault.com/questions/1023949