我正在尝试按照视频教程之一在 Ubuntu 18.04 64 位上安装wireguard。
步骤结束于systemctl start [email protected]
Job for [email protected] failed because the control process exited with error code.
See "systemctl status [email protected]" and "journalctl -xe" for details.
运行给出:systemctl status [email protected]
● [email protected] - WireGuard via wg-quick(8) for wg0
Loaded: loaded (/lib/systemd/system/[email protected]; indirect; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2023-03-11 00:02:48 UTC; 7min 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
Process: 18984 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=1/FAILURE)
Main PID: 18984 (code=exited, status=1/FAILURE)
Mar 11 00:02:48 my-vps.name systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
Mar 11 00:02:48 my-vps.name wg-quick[18984]: [#] ip link add wg0 type wireguard
Mar 11 00:02:48 my-vps.name wg-quick[18984]: RTNETLINK answers: Operation not supported
Mar 11 00:02:48 my-vps.name wg-quick[18984]: Unable to access interface: Protocol not supported
Mar 11 00:02:48 my-vps.name wg-quick[18984]: [#] ip link delete dev wg0
Mar 11 00:02:48 my-vps.name wg-quick[18984]: Cannot find device "wg0"
Mar 11 00:02:48 my-vps.name systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE
Mar 11 00:02:48 my-vps.name systemd[1]: [email protected]: Failed with result 'exit-code'.
Mar 11 00:02:48 my-vps.name systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.
跑步journalctl -xe
节目:
Mar 10 23:46:27 my-vps.name wg-quick[18951]: [#] ip link add wg0 type wireguard
Mar 10 23:46:27 my-vps.name wg-quick[18951]: RTNETLINK answers: Operation not supported
Mar 10 23:46:27 my-vps.name wg-quick[18951]: Unable to access interface: Protocol not supported
Mar 10 23:46:27 my-vps.name wg-quick[18951]: [#] ip link delete dev wg0
Mar 10 23:46:27 my-vps.name wg-quick[18951]: Cannot find device "wg0"
我的wg0.conf
样子:
[Interface]
PrivateKey = myprivatekeyhere
Address = 10.0.0.1/24
ListenPort = 51830
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o venet0 -j MASQUERADE
modprobe wireguard
说:
modprobe: FATAL: Module wireguard not found in directory /lib/modules/4.15.0
ls /lib/modules
返回:
4.15.0 4.15.0-206-generic
uname -r
显示:
4.15.0
重新启动没有帮助。搜索没有帮助。
答案1
所以,是的,正如错误所说:您的内核没有wireguard模块,因此无法执行wireguard。
您需要构建并安装wireguard模块(因为您使用的是非常旧的发行版,内核很旧,所以内核中没有wireguard,您需要单独安装它;如果您启用了universe repos,请安装wireguard-dkms
。更好,更新到更现代的 Ubuntu;从那时起,任何具有 Linux 内核 > 5.6 的系统都可能包含wireguard 模块;因此,请选择 Ubuntu 22.04)