大网数据广告活动
服务器运维问答

Running wg-quick up wg0 is altering my /etc/wireguard/wg0.conf file

· 52CE 我爱测

Im using debian 11 server on my VPS, and trying to setup wireguard. after creating my private and public keys, i create my config file /etc/wireguard/wg0.conf with contents [Interface] PrivateKey = [PRV_KEY] Address = 192.168.23.…

问题原文

原帖链接 · Rachel1983 · CC BY-SA 4.0

Im using debian 11 server on my VPS, and trying to setup wireguard.

after creating my private and public keys, i create my config file /etc/wireguard/wg0.conf with contents

[Interface]
PrivateKey = [PRV_KEY]
Address = 192.168.23.1/24
ListenPort = 51820
SaveConfig = true

[peer]
PublicKey = [PUB_KEY]
AllowedIPs = 192.168.23.2

Calling wg-quick up wg0

[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 192.168.23.1/24 dev wg0
[#] ip link set mtu 1420 up dev wg0

ip addr shows the new wg0 interface

Now my /etc/wireguard/wg0.conf has been altered to

[Interface]
Address = 192.168.23.1/24
SaveConfig = true
ListenPort = 51820
PrivateKey = [PRV_KEY]

the [peer] block is completely missing.

As I am new to wireguard and VPNS, im assuming without this peer block being parsed, I dont have a public key...

已采纳解答

原帖链接 · vidarlo · CC BY-SA 4.0

SaveConfig = true

SaveConfig — if set to `true', the configuration is saved from the current state of the interface upon shutdown. Any changes made to the configuration file before the interface is removed will therefore be overwritten.

Taken from man wg-quick. Remove that line.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2024-03-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。