sta*_*tic 28 router routing ip arp
路由顺序是否重要:
> route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
123.x.x.151 0.0.0.0 255.255.255.255 UH 0 0 0 vmbr0
123.x.x.154 0.0.0.0 255.255.255.255 UH 0 0 0 vmbr0
123.x.x.128 0.0.0.0 255.255.255.224 U 0 0 0 vmbr0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 vmbr1
0.0.0.0 123.x.x.129 0.0.0.0 UG 0 0 0 vmbr0
Run Code Online (Sandbox Code Playgroud)
是否与以下相同:
> route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
123.x.x.128 0.0.0.0 255.255.255.224 U 0 0 0 vmbr0
123.x.x.151 0.0.0.0 255.255.255.255 UH 0 0 0 vmbr0
123.x.x.154 0.0.0.0 255.255.255.255 UH 0 0 0 vmbr0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 vmbr1
0.0.0.0 123.x.x.129 0.0.0.0 UG 0 0 0 vmbr0
Run Code Online (Sandbox Code Playgroud)
?
不同之处在于
123.x.x.128 123.x.x.129 255.255.255.224 U 0 0 0 vmbr0
Run Code Online (Sandbox Code Playgroud)
高于
123.x.x.151 0.0.0.0 255.255.255.255 UH 0 0 0 vmbr0
Run Code Online (Sandbox Code Playgroud)
所以如果我发送到123.x.x.151它会去哪里:
- the routed way over `123.x.x.129`, because it matches the `123.x.x.128` rule, or
- the direct way using the arp table, because it matches the `123.x.x.151` rule
Run Code Online (Sandbox Code Playgroud)
?
use*_*686 35
表中的顺序无关紧要;具有较长前缀的路由始终优先。如果您不再执着于网络掩码,而是考虑前缀长度(如图ip route所示),您将拥有123.x.x.128/27and 123.x.x.151/32,而后者——更具体的——路由将优先于前者(更通用的路线)。
仅当您有重复的路线时,订单才重要。不要那样做。
例如,如果两个接口具有相同的目标、网络掩码和网关 0.0.0.0,则第一个接口将获取该网络的所有流量。
更重要的是,我发现有些系统会在启动时随机重新排序,哪个先出现。如果只有一个工作,或者只有一个设置了路由器网关,这可能会导致在重新启动时无法访问该网络。