05-26-2013 04:21 PM - edited 03-07-2019 01:34 PM
I was working on a project and I need to parse the output of "show ip route":
Below is the output:
---sho ip route---
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 172.20.20.37 to network 0.0.0.0
O IA 192.17.243.0/29 [110/125] via 172.20.20.41, 00:23:23, Vlan3514
[110/235] via 172.20.20.37, 00:23:23, Vlan3513
This last entry is due to OSPF but for same destination there are 2 entries how do we interpret this ? I need to parse each entry. Also how do we determine the outgoing interface for a packet with destination 192.17.61.0 ?
Solved! Go to Solution.
05-26-2013 06:13 PM
The entries in the routing table indicate that OSPF has found two paths toward the destination and that each of the paths has the same metric. So both entries are present in the IP routing table.
The result is load sharing for outbound traffic. For one destination the router will select 172.20.20.37and for the next destination the router will select 172.20.20.41 for the next hop, and the next hop will alternate between these two addresses as the next hop. So if you know the next hop selected for the last packet then you can predict the next hop for the next packet. But if you do not know the next hop for the last packet then predicting the next hop for the next hop will have a 50% chance of choosing the right next hop for the next packet.
HTH
Rick
05-26-2013 06:13 PM
The entries in the routing table indicate that OSPF has found two paths toward the destination and that each of the paths has the same metric. So both entries are present in the IP routing table.
The result is load sharing for outbound traffic. For one destination the router will select 172.20.20.37and for the next destination the router will select 172.20.20.41 for the next hop, and the next hop will alternate between these two addresses as the next hop. So if you know the next hop selected for the last packet then you can predict the next hop for the next packet. But if you do not know the next hop for the last packet then predicting the next hop for the next hop will have a 50% chance of choosing the right next hop for the next packet.
HTH
Rick
05-26-2013 07:17 PM
Thankyou for the explanation.
Also the entries have VLAN's mentioned in place of outgoing interface so in that case consider if a packet comes for 192.17.243.33 in that case is the packet broadcasted on all ports belonging to Vlan3514.
05-26-2013 07:35 PM
In these entries the vlan mentioned functions as the outgoing interface. So a packet whose destination is 192.17.243.33 will match entry
O IA 192.17.243.32/28 [110/320] via 172.20.20.41, 00:23:23, Vlan3514
So this entry specifies not only the outgoing interface of vlan 3514 but also the next hop address of 172.20.20.41. So the packet will not be broadcaast to all ports but will be unicast to the next hop address.
HTH
Rick
05-26-2013 08:21 PM
Sorry I dont have a switch to try out but when the next hop 172.20.20.41 is on another switch how does vlan 3514 know which interface it should use to send the packet.
Does it use the MAC address of 172.20.20.41 to determine which outgoing port it is ?
05-27-2013 06:38 AM
Yes it does use the MAC address. Here is the detail of what it does:
- it is forwarding a packet to 192.17.243.33 and looks in the routing table and finds that the next hop is 172.20.20.41 in vlan 3514.
- it looks in its arp table for 172.20.20.41 and finds its MAC address (in vlan 3514)
- it looks in its mac-address table for the MAC address which will identify the interface to use to get to that address.
- it then forwards the packet out the appropriate interface to reach the next hop.
HTH
Rick
05-29-2013 10:27 AM
thank you.
06-05-2013 07:06 PM
Rick
I did not get the part: how did it determined the outgoing interface for the vlan case ?
thanks.
06-05-2013 07:14 PM
I am not clear what vlan case you are asking about. Please clarify your question.
HTH
Rick
06-05-2013 07:26 PM
From your reply in one of the above comments : When the outgoing interface mentioned in the routing table is a Vlan
( e.g. - O IA 192.17.243.32/28 [110/320] via 172.20.20.41, 00:23:23, Vlan3514 )
Yes it does use the MAC address. Here is the detail of what it does:
- it is forwarding a packet to 192.17.243.33 and looks in the routing table and finds that the next hop is 172.20.20.41 in vlan 3514.
- it looks in its arp table for 172.20.20.41 and finds its MAC address (in vlan 3514)
- it looks in its mac-address table for the MAC address which will identify the interface to use to get to that address.
- it then forwards the packet out the appropriate interface to reach the next hop.
In this case in point 3 - how is the interface detail obtained ?
06-05-2013 07:53 PM
In point three the mac-address table is a table that associates a mac address with the interface which the switch will use to forward to that mac address. This is part of the basic layer 2 forwarding behavior of the switch. so you look in the arp table to find the mac and then you look up that mac in the mac-address table to find the interface.
HTH
Rick
06-20-2013 07:35 PM
Rick,
if I need to view the table with IP-MAC binding with actual physical interface do we use "show ip arp detail" command or this info is stored in some other table.
06-20-2013 09:08 PM
I do not clearly understand your question. So let me suggest this answer based on what I believe that you are asking and if it does not sufficiently address your question then I ask that you provide clarification of the question.
Let me start the explanation by making clear that there are two tables which must be used to find the interface through which the packet will be forwarded. 1) the layer 3 forwarding process uses the ARP table to associate the destination IP address with its correct destination MAC address. 2) the layer 2 forwarding process uses the mac-address-table (the name may vary somewhat depending on the model of the switch) to associate a destination mac address and its correct outbound interface.
So you would begin your search by using the show ip arp command. (I do not believe that the detail parameter would be required.) This is where the IP-MAC binding is stored.
Once you have found the correct answer in the IP-MAC binding table then you would use show mac-address-table to find the correct interface through which the packet would be forwarded.
HTH
Rick
06-21-2013 08:50 AM
Yeah Rick thats what I was looking for. thanks.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide