WireGuard:wg-quick:“/etc/wireguard/wg0.conf”不存在

WireGuard:wg-quick:“/etc/wireguard/wg0.conf”不存在

我正在尝试在 WireGuard 的帮助下在我的服务器上设置 VPN。我正在关注这个教程https://upcloud.com/resources/tutorials/get-started-wireguard-vpn

在我采取行动之后,我遇到了这个错误

systemctl status wg-quick@wg0
× [email protected] - WireGuard via wg-quick(8) for wg0
     Loaded: loaded (/lib/systemd/system/[email protected]; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2023-07-17 08:31:15 UTC; 15h ago
       Docs: man:wg-quick(8)
             man:wg(8)
             https://www.wireguard.com/
             https://www.wireguard.com/quickstart/
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
   Main PID: 5700 (code=exited, status=1/FAILURE)
        CPU: 5ms

Jul 17 08:31:15 v1567418.hosted-by-vdsina.ru systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
Jul 17 08:31:15 v1567418.hosted-by-vdsina.ru wg-quick[5700]: wg-quick: `/etc/wireguard/wg0.conf' does not exist
Jul 17 08:31:15 v1567418.hosted-by-vdsina.ru systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE
Jul 17 08:31:15 v1567418.hosted-by-vdsina.ru systemd[1]: [email protected]: Failed with result 'exit-code'.
Jul 17 08:31:15 v1567418.hosted-by-vdsina.ru systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.

我的行动:

文件 sudo nano /etc/sysctl.conf 中取消注释的行 net.ipv4.ip_forward=1

应用以下更改

sudo sysctl -p

配置/etc/wireguard/wg0.conf

[Interface]
Address = 10.66.66.1/24,fd42:42:42::1/64
ListenPort = 58723
PrivateKey = XXXXX


PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;ip6tables -A FORWARD -i %i -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;

PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;ip6tables -D FORWARD -i %i -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;


[Peer]
# Client Name: Unnamed
PublicKey = MY__PUB_KEY
AllowedIPs = 10.66.66.2/32,fd42:42:42::2/128

然后我就开始WG

> wg-quick up wg0
wg-quick: `wg0' already exists

然后我启用 WG 自动启动

systemctl enable wg-quick@wg0

有用的信息

ls /etc/wireguard
wg0.conf


# /lib/systemd/system/[email protected]
[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
ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)'
Environment=WG_ENDPOINT_RESOLUTION_RETRIES=infinity

[Install]
WantedBy=multi-user.target

答案1

嘿,我面临着类似的问题..最终用质子进行设置: https://protonvpn.com/support/wireguard-manual-linux/

相关内容