cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
5255
Views
5
Helpful
9
Replies
Highlighted
Beginner

What is the best way to find out how your router will route traffic for a particular ip address?

Hi All

What is the best way to find out how your router will route traffic to a particular ip address?

I have used the following IOS command:

show ip route | include X.X.X

where X.X.X is the 1st 3 octets of the ip address. I can then see the particular entry in the routing table.

I think this really assumes that the entry in the routing table is /24, as below this (e.g. /16), I couldn't know that the 3rd octet is the same as the ip address I want to find out about - and therefore this could fail.

What I wanted to know is:

a) Is there some other command that a specific ip address can be entered that IOS will use to query the routing table for a particular ip address and return the ip address/next hop it will route it to?

b) I don't understand properly in a routing table what range of subnet masks can be used. Looking at the table on our router, I can see /24, /18, /22. Therefore, if any mask can appear in a routing table, if I use my search method above of "include X.X.X", I think this could fail - as if the subnet is /16, then the 3rd octet X in the ip routing table entry might not be the same as the ip address I'm searching for. Therefore, my method is fundamentally flawed!

I hope this is clear!

Thanks in advance for all responses!

John

Everyone's tags (4)
4 ACCEPTED SOLUTIONS

Accepted Solutions
VIP Expert

What is the best way to find out how your router will route traf

Hi John,

Although not very intuitive and easy, there are several options when issuing "sh ip route".  You can add the subnet and the exact mask or use the prefix command.  One of best option that is available in other vendors routers that use Linux based OS is the "match" command, but unfortunately this command is not available in IOS.

Any way, Have a look at the command reference guide for more info:

http://www.cisco.com/en/US/docs/ios/ipaddr/command/reference/iad_ip.html#wp1046076

HTH

Advisor

What is the best way to find out how your router will route traf

Hi,

just do sh ip route x.x.x.x where x.x.x.x is your destination IP address.

Regards.

Alain

Don't forget to rate helpful posts.
Hall of Fame Cisco Employee

What is the best way to find out how your router will route traf

Hello,

Just to add to Alain's already perfect answers, the description of the show ip route command can be found, for example, here:

http://www.cisco.com/en/US/docs/ios/iproute_pi/command/reference/iri_pi2.html#wp1042302

Also one gotcha: when using the show ip route N.N.N.N command, if the only route matching the IP address N.N.N.N is the default route, the router will surprisingly tell you that the route is not in the routing table. In other words, when used with a particular destination IP address, this command will print out only those routes that are more specific than the default route.

Best regards,

Peter

What is the best way to find out how your router will route traf

Just to add to Peters gotcha:

show ip cef ip-address: This command is similar to the show ip route ip-address command, but it searches the FIB rather than the routing table. Therefore, the displayed  results do not include any routing protocol-related information, but  only the information necessary to forward packets. (Note that this  command will display the default route if it is the best match for a  particular IP address.)

Bit of trivia really as if you do show ip route and see you have a default route listed you then know any prefixes that come back as "Subnet not in routing table" will be routed to default route next hop...but it's still nice to know!

9 REPLIES 9
VIP Expert

What is the best way to find out how your router will route traf

Hi John,

Although not very intuitive and easy, there are several options when issuing "sh ip route".  You can add the subnet and the exact mask or use the prefix command.  One of best option that is available in other vendors routers that use Linux based OS is the "match" command, but unfortunately this command is not available in IOS.

Any way, Have a look at the command reference guide for more info:

http://www.cisco.com/en/US/docs/ios/ipaddr/command/reference/iad_ip.html#wp1046076

HTH

Advisor

What is the best way to find out how your router will route traf

Hi,

just do sh ip route x.x.x.x where x.x.x.x is your destination IP address.

Regards.

Alain

Don't forget to rate helpful posts.
Beginner

What is the best way to find out how your router will route traf

Hi Alain

Thanks! That gave exactly the output that I wanted (see below). Out of interest (please don't bother if you don't know off the top of your head as I can easily google it), do you know a link to a site that explains the output - I'm particularly interested in understanding the "distance"/"metric"/"traffic share count" which I guess is the cost of the route. Our routers will be picking up routes from 3 bgp peers and then 2 ibgp/ospf peers, so I guess this is the information they are using to choose the best route.

John

Routing entry for X.X.X.0/24

  Known via "bgp XXXXX", distance 20, metric 0

  Tag YYYY, type external

  Last update from Z.Z.Z.Z 2w0d ago

  Routing Descriptor Blocks:

  * Z.Z.Z.Z, from Z.Z.Z.Z, 2w0d ago

      Route metric is 0, traffic share count is 1

      AS Hops 3

      Route tag YYYY

Advisor

What is the best way to find out how your router will route traf

Hi,

Routing entry for X.X.X.0/24  The longest match route in the routing table for the destination IP

Known via "bgp XXXXX", distance 20, metric 0   it was inserted in the routing table by eBGP( AD of 20)

Last update from Z.Z.Z.Z 2w0d ago   IP address of the router that advertised this route

traffic share count is 1   no load balancing

AS Hops 3   the route was injected on a router 3 AS hops away so 2 AS hops away from advertising router

AD is a measure of believability of a route, when a router has 2 equal routes from 2 protocols with different AD then it will insert in the routing table the one with lower AD.

for eBGP the metric or MED attribute is zero by default but it has nothing to do with the cost of the route because BGP is using a complex algorithm to select best path which compares attributes unil there is a mismatch.

Regards.

Alain

Don't forget to rate helpful posts.
Beginner

What is the best way to find out how your router will route traf

Hi Alain

Once again, thanks.

No problem if you haven't time to respond to these - but just in case you find them of interest, I have the following queries:

Do you know of a link to an article showing or detailing the algorithm that BGP uses? I would be very interested to know the factors that are involved. I think it would give me a much better understanding of how traffic is routed.

How do other external routing protocols differ from BGP? Is the difference in the type of algorithm that they use for selecting the best path?

ThanksJohn

Hall of Fame Cisco Employee

What is the best way to find out how your router will route traf

Hello,

Just to add to Alain's already perfect answers, the description of the show ip route command can be found, for example, here:

http://www.cisco.com/en/US/docs/ios/iproute_pi/command/reference/iri_pi2.html#wp1042302

Also one gotcha: when using the show ip route N.N.N.N command, if the only route matching the IP address N.N.N.N is the default route, the router will surprisingly tell you that the route is not in the routing table. In other words, when used with a particular destination IP address, this command will print out only those routes that are more specific than the default route.

Best regards,

Peter

What is the best way to find out how your router will route traf

Just to add to Peters gotcha:

show ip cef ip-address: This command is similar to the show ip route ip-address command, but it searches the FIB rather than the routing table. Therefore, the displayed  results do not include any routing protocol-related information, but  only the information necessary to forward packets. (Note that this  command will display the default route if it is the best match for a  particular IP address.)

Bit of trivia really as if you do show ip route and see you have a default route listed you then know any prefixes that come back as "Subnet not in routing table" will be routed to default route next hop...but it's still nice to know!

Hall of Fame Cisco Employee

What is the best way to find out how your router will route traf

Stephen,

Good point! +5 as deserved (Although this would only work if CEF is activated...)

Best regards,

Peter

Beginner

What is the best way to find out how your router will route traf

Thanks to all who have answered. It answered my original question plus has expanded my knowledge of routing alot!

I'm waiting for the day that I can answer somebody else's query - that will be the day that I have arrived!

John

CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards