Ubuntu 到 0.0.0.0 目的地的网关不正确

Ubuntu 到 0.0.0.0 目的地的网关不正确

我的路由器的 IP 地址是 192.168.4.1,但 Ubuntu 对于 0.0.0.0 目的地的网关 (192.168.1.1) 是错误的。

$ sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    202    0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     204    0        0 docker0
169.254.0.0     0.0.0.0         255.255.0.0     U     207    0        0 veth25c3672
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-b0d0fb5e0e31
192.168.1.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0
192.168.4.0     0.0.0.0         255.255.252.0   U     100    0        0 eth0

我在 Raspberry Pi 上运行 Ubuntu 20.10。

编辑:

这是以下的输出ip addr

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:94:9c:f9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.4.111/22 brd 192.168.7.255 scope global dynamic noprefixroute eth0
       valid_lft 13792sec preferred_lft 13792sec
    inet 192.168.1.111/24 brd 192.168.1.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fda1:a63d:515d:3:406:1189:9d9a:cb0a/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 1763sec preferred_lft 1763sec
    inet6 fe80::dea6:32ff:fe94:9cf9/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether dc:a6:32:94:9c:fa brd ff:ff:ff:ff:ff:ff
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:84:54:17 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet 169.254.144.13/16 brd 169.254.255.255 scope global noprefixroute docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::1aae:616e:f298:1a57/64 scope link 
       valid_lft forever preferred_lft forever
5: br-b0d0fb5e0e31: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:c2:38:d1:89 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-b0d0fb5e0e31
       valid_lft forever preferred_lft forever
7: veth25c3672@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether 5e:70:b9:32:6d:76 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 169.254.131.198/16 brd 169.254.255.255 scope global noprefixroute veth25c3672
       valid_lft forever preferred_lft forever
    inet6 fe80::2171:b3e8:2409:538a/64 scope link 
       valid_lft forever preferred_lft forever
    inet6 fe80::5c70:b9ff:fe32:6d76/64 scope link 
       valid_lft forever preferred_lft forever

我还运行了这个命令:

systemctl stop dhcpcd ; rm /var/lib/dhcpcd*/*lease* ; systemctl start dhcpcd

但坏网关191.168.1.1仍然出现eth0

$ sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    202    0        0 eth0
0.0.0.0         192.168.4.1     0.0.0.0         UG    20100  0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     204    0        0 docker0
169.254.0.0     0.0.0.0         255.255.0.0     U     207    0        0 veth25c3672
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-b0d0fb5e0e31
192.168.1.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0
192.168.4.0     0.0.0.0         255.255.252.0   U     100    0        0 eth0

答案1

inet 192.168.4.111/22 brd 192.168.7.255 scope global dynamic noprefixroute eth0
   valid_lft 13792sec preferred_lft 13792sec

上面显示它来自 DHCP。

而下面的内容向我们展示了它是静态的。最有可能通过 NetworkManager。在那里删除它。

inet 192.168.1.111/24 brd 192.168.1.255 scope global noprefixroute eth0
   valid_lft forever preferred_lft forever

相关内容