2

Just out of curiosity, let's say I have a forwarding table in an IP router that looks like this:

134.50.56.0/22    Interface 4
134.50.60.0/22    Interface 3
192.53.40.0/23    Interface 2
default           Interface 1

The router have the following incomming datagrams to deal with:

1) 134.50.63.9
2) 134.50.57.13
3) 134.50.52.3
4) 192.53.40.6
5) 192.53.56.7

Does the forwarding plane use the longest prefix matching rule here to determine on which interface the datagram should be forwarded?

Then datagram 1 should be sent to interface 3, 2->4, 3->4, 4->2 and 5->2...? Right?

1 Answers1

1

No, datagrams 3 and 5 will be send to the default gateway through interface 1, because there is no subnet route to these destinations.

Check out the output of sipcalc:

$ sipcalc 134.50.56.0/22
-[ipv4 : 134.50.56.0/22] - 0

[CIDR]
Host address            - 134.50.56.0
Host address (decimal)  - 2251438080
Host address (hex)      - 86323800
Network address         - 134.50.56.0
Network mask            - 255.255.252.0
Network mask (bits)     - 22
Network mask (hex)      - FFFFFC00
Broadcast address       - 134.50.59.255
Cisco wildcard          - 0.0.3.255
Addresses in network    - 1024
Network range           - 134.50.56.0 - 134.50.59.255
Usable range            - 134.50.56.1 - 134.50.59.254

The 3rd datagram, with IP address 134.50.52.3, is not within the range of this network, and this is the same for packet n°5.

An interesting reading is Evan answer at How does ipv4 subnetting works.

petrus
  • 5,297
  • 26
  • 42