23
4
Does the routing order matter:
> 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
is it the same as:
> 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
?
where the difference is, that
123.x.x.128 123.x.x.129 255.255.255.224 U 0 0 0 vmbr0
is higher order than
123.x.x.151 0.0.0.0 255.255.255.255 UH 0 0 0 vmbr0
so if I send to 123.x.x.151
where will it go:
- 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
?
2What happens if there are eqal sized masks? E.g. 10.0.0.0/24 and 192.168.0.0/24. – ManuelSchneid3r – 2016-02-04T21:57:41.693
3@ManuelSchneid3r: Nothing happens. Routes are only considered if they actually match the destination, and an IP address obviously cannot start with
10.
and192.
at the same time, so it will only match one of those masks in the first place. – user1686 – 2016-02-05T05:37:22.6931what if you have two interfaces on the same IP space? – MikeSchem – 2018-07-26T20:25:23.757
@MikeSchem: Then the 'metric' parameter of both routes is used. (The OS will usually refuse to add two routes with identical prefix, identical prefixlen, and identical metric, or possibly merge them into an ECMP load-balanced route.) – user1686 – 2018-07-26T20:34:07.157