我跑了
ip route flush all
现在我根本没有路由。要重置我的网络接口,我只需单击网络管理器中的网络,它就会重新连接并正确设置我的所有本地网络路由。
Docker 以前有以下路线。
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
63020b1cb1d1 bridge bridge local
a762e757a6f2 dtestnet bridge local
42ebdc968b28 dtestnet2 bridge local
5a70e302ed35 host host local
50bd71cfe87f none null local
e79fd5be2161 ssh-systemd-ubuntu_default bridge local
$ ip r l
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.18.0.0/16 dev br-a762e757a6f2 proto kernel scope link src 172.18.0.1 linkdown
172.20.0.0/16 dev br-42ebdc968b28 proto kernel scope link src 172.20.0.1 linkdown
172.22.0.0/16 dev br-c1a38add5116 proto kernel scope link src 172.22.0.1
172.23.0.0/16 dev br-411e2604e9b1 proto kernel scope link src 172.23.0.1
我在重启之前没有包含这些详细信息docker network prune
。因此这只显示一个 docker0 接口
ip l l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 04:92:26:02:4b:a2 brd ff:ff:ff:ff:ff:ff
3: wlo1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DORMANT group default qlen 1000
link/ether 2e:26:42:d5:dc:e0 brd ff:ff:ff:ff:ff:ff
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default
link/ether f2:99:b9:9a:2c:91 brd ff:ff:ff:ff:ff:ff
现在它只剩下我的本地路线。docker network ls
仍然显示上面相同的 docker 网络列表。
由于没有到实际容器的路由,我的 docker 镜像都无法工作。我还重新启动了 docker.service、NetworkManager.service 服务,但无法恢复网络路由和接口。
systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2019-03-07 16:21:59 SAST; 1min 39s ago
Docs: https://docs.docker.com
Main PID: 24556 (dockerd)
Tasks: 47 (limit: 4915)
Memory: 65.1M
CGroup: /system.slice/docker.service
├─24556 /usr/bin/dockerd -H fd://
└─24574 containerd --config /var/run/docker/containerd/containerd.toml --log-level inf
此外
如果我使用 ip link [dev] [up/down],它会重新添加路由,但链接仍然显示关闭。
ip l set docker0 down
ip r l
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
我看到 systemd 中列出了与 docker 服务相关的设备。这些是设备文件,我不确定它们之间有什么关系
systemctl list-units | grep docker
sys-devices-virtual-net-docker0.device loaded active plugged /sys/devices/virtual/net/docker0
sys-subsystem-net-devices-docker0.device loaded active plugged /sys/subsystem/net/devices/docker0
docker.service loaded active running Docker Application Container Engine
docker.socket loaded active running Docker Socket for the API
Docker 通过桥接设备设置网络链接。桥接设备有些功能无法正常工作 https://medium.com/@xiaopeng163/docker-bridge-networking-deep-dive-3e2e0549e8a0 https://developer.ibm.com/recipes/tutorials/networking-your-docker-containers-using-docker0-bridge/
brctl show
bridge name bridge id STP enabled interfaces
br-0fce78dfb0da 8000.024289a30906 no
br-95173e3c7322 8000.02426a728db1 no
docker0 8000.f299b99a2c91 no
启动 docker 容器时,它们应该自动连接到网桥并开始工作。我需要查找有关修复 Linux 中的网桥设置的更多信息。
ip r l t local
broadcast 127.0.0.0 dev lo proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
broadcast 172.17.0.0 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
local 172.17.0.1 dev docker0 proto kernel scope host src 172.17.0.1
broadcast 172.17.255.255 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
broadcast 172.18.0.0 dev br-95173e3c7322 proto kernel scope link src 172.18.0.1 linkdown
local 172.18.0.1 dev br-95173e3c7322 proto kernel scope host src 172.18.0.1
broadcast 172.18.255.255 dev br-95173e3c7322 proto kernel scope link src 172.18.0.1 linkdown
broadcast 172.19.0.0 dev br-0fce78dfb0da proto kernel scope link src 172.19.0.1 linkdown
local 172.19.0.1 dev br-0fce78dfb0da proto kernel scope host src 172.19.0.1
broadcast 172.19.255.255 dev br-0fce78dfb0da proto kernel scope link src 172.19.0.1 linkdown
答案1
我可以通过重新启动主机来解决这个问题。
这将正确启动所有服务,只要我不重复执行,一切都会正常工作route flush all
。
我仍然想了解这些位和部分如何工作,以便通过重新启动或重新配置正确的服务或路由来解决这个问题。