I want to know how Linux uses routing table when reaching out to another ip. As i know for example when we run "ssh 192.168.21.2", system will create the tcp packet with destination ip as 192.168.21.2 and refer routing table for next hop. the routing table entries as shown below:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.16.1 0.0.0.0 UG 0 0 0 br0
169.254.0.0 0.0.0.0 255.255.0.0 U 1005 0 0 br0
169.254.0.0 0.0.0.0 255.255.0.0 U 1006 0 0 br1
192.168.16.0 0.0.0.0 255.255.240.0 U 0 0 0 br0
192.168.66.0 0.0.0.0 255.255.255.128 U 0 0 0 br1
Here system will find the destination network address and match it with the network address of destination and if match found send that packet to respective gateway via interface.
My doubt is how and when system is calculating the network address of destination ip in order to match it with routing table. I may be entirely wrong on this flow. need explanation to understand the packet flow from system.
routecommand. I.e.ip route show.