WG 常见Docker 无法启动解决方案

TAIDONG 2023-05-24 PM 968℃ 0条

实践环境:CentOS8

1.Docker无法启动问题

docker logs -f 6b56126963dc21cdc515d6c758f1d949c55f203d36542b27e360ddbc556ae80a
2022-06-15T05:34:33.902Z Server Listening on http://0.0.0.0:51821
2022-06-15T05:34:33.903Z WireGuard Loading configuration...
2022-06-15T05:34:33.905Z WireGuard Configuration loaded.
2022-06-15T05:34:33.905Z WireGuard Config saving...
2022-06-15T05:34:33.906Z WireGuard Config saved.
$ wg-quick down wg0
$ wg-quick up wg0
Error: Command failed: wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.8.0.1/24 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] iptables -t nat -A POSTROUTING -s 192.0.2.0/24 -o eth0 -j MASQUERADE; iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT; iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT;
modprobe: can't change directory to '/lib/modules': No such file or directory
modprobe: can't change directory to '/lib/modules': No such file or directory
iptables v1.8.3 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
[#] ip link delete dev wg0

    at ChildProcess.exithandler (child_process.js:383:12)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1058:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5) {
  killed: false,
  code: 3,
  signal: null,
  cmd: 'wg-quick up wg0'
}

解决方案

modprobe ip_tables && modprobe iptable-nat

2.Upgrade Linux Kernel of CentOS 8

dnf -y update

2023-05-24T13:19:01.png

uname -r

2023-05-24T13:19:49.png

dnf install -y https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm

2023-05-24T13:20:32.png

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

dnf makecache

2023-05-24T13:21:12.png

dnf --disablerepo="*" --enablerepo="elrepo-kernel" list available | grep kernel-ml

2023-05-24T13:21:47.png

dnf --enablerepo="elrepo-kernel" install -y kernel-ml

2023-05-24T13:22:19.png

reboot

uname -r

2023-05-24T13:23:01.png

标签: Wireguard, Docker, CentOS

非特殊说明,本博所有文章均为博主原创。

评论啦~


选择表情