在 Ubuntu 20.04 (Focal) 上,我能够使用这个问题通过常规 Gnome VPN 管理来管理我的 WireGuard VPN 连接。但是,这在 22.04(Jammy)中不再起作用。插件构建得很好,我可以导入我的配置文件(如果我使用,它可以工作wg-quick up
,所以我不认为这是一个配置文件问题),新的 VPN 配置出现在 VPN 列表中。但是,尝试激活它会导致“激活网络连接失败”并且无法连接到服务器。
以下是尝试连接时的系统日志:
Apr 26 10:33:53 eins NetworkManager[628]: <info> [1650990833.9975] vpn[0x5579356748a0,9f61621d-bde7-4714-a668-84cb5fec16b0,"wg0"]: starting wireguard
Apr 26 10:33:53 eins NetworkManager[628]: <info> [1650990833.9987] audit: op="connection-activate" uuid="9f61621d-bde7-4714-a668-84cb5fec16b0" name="wg0" pid=57075 uid=1000 result="success"
Apr 26 10:33:54 eins NetworkManager[59112]: [#] ip link add wg0 type wireguard
Apr 26 10:33:54 eins NetworkManager[59112]: [#] wg setconf wg0 /dev/fd/63
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0255] manager: (wg0): new WireGuard device (/org/freedesktop/NetworkManager/Devices/19)
Apr 26 10:33:54 eins systemd-udevd[59126]: Using default interface naming scheme 'v249'.
Apr 26 10:33:54 eins NetworkManager[59112]: [#] ip -4 address add 10.252.1.3/32 dev wg0
Apr 26 10:33:54 eins NetworkManager[59112]: [#] ip link set mtu 1420 up dev wg0
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0325] device (wg0): state change: unmanaged -> unavailable (reason 'connection-assumed', sys-iface-state: 'external')
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0328] device (wg0): state change: unavailable -> disconnected (reason 'connection-assumed', sys-iface-state: 'external')
Apr 26 10:33:54 eins NetworkManager[59142]: [#] resolvconf -a tun.wg0 -m 0 -x
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0333] device (wg0): Activation: starting connection 'wg0' (5d9bcb5e-0485-4422-8466-24a04ff77b9f)
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0334] device (wg0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'external')
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0336] device (wg0): state change: prepare -> config (reason 'none', sys-iface-state: 'external')
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0337] device (wg0): state change: config -> ip-config (reason 'none', sys-iface-state: 'external')
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0339] device (wg0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'external')
Apr 26 10:33:54 eins dbus-daemon[626]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.11' (uid=0 pid=628 comm="/usr/sbin/NetworkManager --no-daemon " label="unconfined")
Apr 26 10:33:54 eins NetworkManager[59112]: [#] wg set wg0 fwmark 51820
Apr 26 10:33:54 eins NetworkManager[59112]: [#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
Apr 26 10:33:54 eins NetworkManager[59112]: [#] ip -4 rule add not fwmark 51820 table 51820
Apr 26 10:33:54 eins NetworkManager[59112]: [#] ip -4 rule add table main suppress_prefixlength 0
Apr 26 10:33:54 eins NetworkManager[59112]: [#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
Apr 26 10:33:54 eins NetworkManager[59112]: [#] nft -f /dev/fd/63
Apr 26 10:33:54 eins nm-wireguard-se[59109]: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed
Apr 26 10:33:54 eins nm-wireguard-se[59109]: g_variant_builder_add_value: assertion '!GVSB(builder)->expected_type || g_variant_is_of_type (value, GVSB(builder)->expected_type)' failed
Apr 26 10:33:54 eins NetworkManager[628]: <warn> [1650990834.0568] vpn[0x5579356748a0,9f61621d-bde7-4714-a668-84cb5fec16b0,"wg0",if:17,dev:3:(wg0)]: config: no VPN gateway address received
Apr 26 10:33:54 eins NetworkManager[628]: <warn> [1650990834.0568] vpn[0x5579356748a0,9f61621d-bde7-4714-a668-84cb5fec16b0,"wg0",if:17,dev:3:(wg0)]: did not receive valid IP config information
Apr 26 10:33:54 eins systemd[1]: Starting Network Manager Script Dispatcher Service...
Apr 26 10:33:54 eins NetworkManager[59185]: [#] ip -4 rule delete table 51820
Apr 26 10:33:54 eins NetworkManager[59185]: [#] ip -4 rule delete table main suppress_prefixlength 0
Apr 26 10:33:54 eins dbus-daemon[626]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Apr 26 10:33:54 eins systemd[1]: Started Network Manager Script Dispatcher Service.
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0715] device (wg0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'external')
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0716] device (wg0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'external')
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0719] device (wg0): Activation: successful, device activated.
Apr 26 10:33:54 eins NetworkManager[59185]: [#] ip link delete dev wg0
Apr 26 10:33:54 eins NetworkManager[628]: <info> [1650990834.0803] device (wg0): state change: activated -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
Apr 26 10:33:54 eins gnome-shell[2576]: Removing a network device that was not added
Apr 26 10:33:54 eins NetworkManager[59185]: [#] resolvconf -d tun.wg0 -f
Apr 26 10:33:54 eins NetworkManager[59185]: [#] nft -f /dev/fd/63
答案1
有同样的问题。这里的 shell 命令(https://www.reddit.com/r/WireGuard/comments/us1blx/comment/i9klpio/?utm_source=share&utm_medium=web2x&context=3) 对我来说很好用。至少现在右上角的下拉菜单中显示了连接。在“设置”对话框中,它仍然缺失。
编辑:
nmcli connection import type wireguard file "/path/to/wg0.conf"
nmcli connection modify wg0 connection.id "home-vpn"
nmcli connection show home-vpn
导入配置后,它将不会显示在 Gnome 网络设置中。
为了解决每次启动后自动激活的连接的问题,您可以随后编辑连接nm-connection-editor
并停用相关选项。
答案2
对我有用的是使用这个 gtk 客户端。
https://github.com/UnnoTed/wireguird
我之前尝试过所有其他方法,但到目前为止都没有效果。这个客户端解决了我需要的所有问题。它没有与 nm 集成,但仍然是一个很棒的工具。