在 Ubuntu 18.04 上,当我列出我的路线时,我得到以下输出:
root@ubuntu1804:~# ip route ls
default via 192.168.122.1 dev ens3 proto dhcp src 192.168.122.236 metric 100
192.168.122.0/24 dev ens3 proto kernel scope link src 192.168.122.236
192.168.122.1 dev ens3 proto dhcp scope link src 192.168.122.236 metric 100
我不明白为什么192.168.122.1
列出第二个条目以及为什么它没有掩码。它似乎是网关的 IP,但这在其他发行版上不会发生。以下是我的网络配置:
root@ubuntu1804:~# ifconfig
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.122.236 netmask 255.255.255.0 broadcast 192.168.122.255
inet6 fe80::5054:ff:fe83:1bdf prefixlen 64 scopeid 0x20<link>
ether 52:54:00:83:1b:df txqueuelen 1000 (Ethernet)
RX packets 657141 bytes 903750345 (903.7 MB)
RX errors 0 dropped 1128 overruns 0 frame 0
TX packets 161481 bytes 12399386 (12.3 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 8366 bytes 15784491 (15.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8366 bytes 15784491 (15.7 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@ubuntu1804:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.122.1 0.0.0.0 UG 100 0 0 ens3
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 ens3
192.168.122.1 0.0.0.0 255.255.255.255 UH 100 0 0 ens3
例如,在 Fedora 中,我看不到这些路线。列出路线时我得到的输出是:
[root@myhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.100.1 0.0.0.0 UG 100 0 0 eth0
0.0.0.0 172.16.100.1 0.0.0.0 UG 101 0 0 eth1
172.16.100.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1
192.168.100.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0