Given the following routing table:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   Metric   Ref   Use   Iface
0.0.0.0         192.168.178.1   0.0.0.0         UG      0        0     0     wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U       0        0     0     eth0
192.168.2.0     192.168.1.1     255.255.255.0   U       0        0     0     eth0
192.168.178.0   0.0.0.0         255.255.255.0   U       9        0     0     wlan0

How would an outgoing packet to the destination 192.168.2.150 be handled?

A. It would be passed to the default router 192.168.178.1 on wlan0.
B. It would be directly transmitted on the device eth0.
C. It would be passed to the default router 255.255.255.0 on eth0.
D. It would be directly transmitted on the device wlan0.
E. It would be passed to the router 192.168.1.1 on eth0.

题解

路由表会从最小范围的网域开始寻找,将 IP 换成二进制表示后,找出拥有最长相同前缀的那个就是了。由于目标地址是 192.168.2.150,所以要看到第 3 列的路由设置。因此答案是选项 E。