启动服务器时,Wireguard 无法启动。日志:
systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
wg-quick[1139]: [#] ip link add wg0 type wireguard
wg-quick[1139]: [#] wg setconf wg0 /dev/fd/63
wg-quick[1139]: [#] ip -4 address add 10.50.0.2/32 dev wg0
wg-quick[1139]: [#] ip link set mtu 1420 up dev wg0
wg-quick[1256]: [#] resolvconf -a tun.wg0 -m 0 -x
wg-quick[1260]: resolvconf: Error: Run lock held by another process for longer than 10 seconds
wg-quick[1139]: [#] ip link delete dev wg0
systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE
systemd[1]: [email protected]: Failed with result 'exit-code'.
systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.
systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
wg-quick[130477]: [#] ip link add wg0 type wireguard
wg-quick[130477]: [#] wg setconf wg0 /dev/fd/63
wg-quick[130477]: [#] ip -4 address add 10.50.0.2/32 dev wg0
wg-quick[130477]: [#] ip link set mtu 1420 up dev wg0
wg-quick[130509]: [#] resolvconf -a tun.wg0 -m 0 -x
wg-quick[130477]: [#] wg set wg0 fwmark 51820
wg-quick[130477]: [#] ip -6 route add ::/0 dev wg0 table 51820
wg-quick[130477]: [#] ip -6 rule add not fwmark 51820 table 51820
wg-quick[130477]: [#] ip -6 rule add table main suppress_prefixlength 0
wg-quick[130577]: [#] ip6tables-restore -n
wg-quick[130477]: [#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
wg-quick[130477]: [#] ip -4 rule add not fwmark 51820 table 51820
wg-quick[130477]: [#] ip -4 rule add table main suppress_prefixlength 0
wg-quick[130477]: [#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
wg-quick[130596]: [#] iptables-restore -n
systemd[1]: Finished WireGuard via wg-quick(8) for wg0
sudo systemctl 猫[电子邮件保护]
[Unit]
Description=WireGuard via wg-quick(8) for %I
After=network-online.target nss-lookup.target
Wants=network-online.target nss-lookup.target
PartOf=wg-quick.target
Documentation=man:wg-quick(8)
Documentation=man:wg(8)
Documentation=https://www.wireguard.com/
Documentation=https://www.wireguard.com/quickstart/
Documentation=https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
Documentation=https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/wg-quick up %i
ExecStop=/usr/bin/wg-quick down %i
Environment=WG_ENDPOINT_RESOLUTION_RETRIES=infinity
[Install]
WantedBy=multi-user.target
sudo cat /etc/wireguard/wg0.conf
[Interface]
PrivateKey = key
Address = 10.50.0.2/32
DNS = 1.1.1.1
[Peer]
PublicKey = key
PresharedKey = key
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 132.132.132.132:48989
PersistentKeepalive=25
答案1
在 WireGuard 配置中禁用 resolvconf:
DNS = off
这将阻止 WireGuard 尝试使用 resolvconf 配置 DNS 设置。