WireGuard VPN:wg0.conf 不存在

问题描述 投票:0回答:1

我正在尝试在 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
linux vpn wireguard
1个回答
0
投票

如果显示

wg-quick: wg0' already exists
,就运行

sudo wg-quick down wg0

然后:

sudo wg-quick up wg0
© www.soinside.com 2019 - 2024. All rights reserved.