How does a router figure out which exit-interface to use?

johnifanx98johnifanx98 Posts: 329Member
Here is network addressing for the IP network
router		network addr		interface		addr
lab_a		192.168.10.0		fa0/0			  192.168.10.1
lab_a		192.168.20.0		s0/0			  192.168.20.1
lab_b		192.168.20.0		s0/0			  192.168.20.2
lab_b		192.168.30.0		fa0/0			  192.168.30.1

To add a static route on lab_a, I run,
lab_a(config)#ip route 192.168.30.0 255.255.255.0 192.168.20.2
With this static route, each packet destined to network 192.168.30.0 will be sent to next hop 192.168.20.2. No problem. However, I am just curious how the router lab_a determines the exit_interface to send the packet out. The router has all the information needed to figure this out. It can iterate through all its interfaces to check which interface is connected to this next hop. However, would it be easier for the router to figure this out if we add the exit_interface, or, does not matter?

Like,
lab_a(config)#ip route 192.168.30.0 255.255.255.0 192.168.20.2 s0/0

Comments

  • pham0329pham0329 Posts: 556Member
    it seems like you answered your own questions as to how a router figure out which exit interface to use.

    Generally, I always use a next-hop address over exit interface when configuring a static routes. When you configure a next-hop address, the router knows where to send the traffic to, and who to ARP for. When you configure an exit interface, the router does not know the next-hop address, and as such, it will arp for the destination IP instead of the next-hop ip. As a result, your arp table, and cef table will be filled with a ton of entries, all pointing to the next hop router. You can run into some weird problems when configure an exit interface for a static route.
  • johnifanx98johnifanx98 Posts: 329Member
    pham0329 wrote: »
    it seems like you answered your own questions as to how a router figure out which exit interface to use.

    Generally, I always use a next-hop address over exit interface when configuring a static routes. When you configure a next-hop address, the router knows where to send the traffic to, and who to ARP for. When you configure an exit interface, the router does not know the next-hop address, and as such, it will arp for the destination IP instead of the next-hop ip. As a result, your arp table, and cef table will be filled with a ton of entries, all pointing to the next hop router. You can run into some weird problems when configure an exit interface for a static route.

    Thanks for reply. As to using exit_interface for static route, it's used only when the exit_interface is a PTP connection. So, it might not trigger arp flooding?

    As to using next_hop address, will the router ARP all its interfaces? Could it be more efficient if specifying the exit_interface combined with the next_hop address, then the router will ARP that exit_interface only?
  • johnifanx98johnifanx98 Posts: 329Member
    pham0329 wrote: »
    it seems like you answered your own questions as to how a router figure out which exit interface to use.

    Generally, I always use a next-hop address over exit interface when configuring a static routes. When you configure a next-hop address, the router knows where to send the traffic to, and who to ARP for. When you configure an exit interface, the router does not know the next-hop address, and as such, it will arp for the destination IP instead of the next-hop ip. As a result, your arp table, and cef table will be filled with a ton of entries, all pointing to the next hop router. You can run into some weird problems when configure an exit interface for a static route.

    Thanks for reply. As to using exit_interface for static route, it's used only when the exit_interface is a PTP connection. So, it might not trigger arp flooding?

    As to using next_hop address, will the router ARP all its interfaces? Could it be more efficient if specifying the exit_interface combined with the next_hop address, then the router will ARP that exit_interface only?
  • Forsaken_GAForsaken_GA Posts: 4,024Member
    When you specify a next hop address, the router will recurse the routing table until it finds a connected route to get to that destination, and then uses that in the cef table (assuming you have cef enabled)

    When you specify an exit interface on a non-p2p link, it will do it's layer2 to 3 resolution for *every* address out that interface. So if you specify any type of ethernet interface as an exit interface for a route, it's going to arp for every single destination address out of that interface. Imagine if you set your default route out an ethernet interface on an internet facing router... you would arp for EVERY ip on the internet that someone tried to contact.

    Generally speaking, you should use next-hop IP's unless you have a really good reason to use interfaces.

    I'd recommend reading the chapter on static routing in Routing TCP/IP, Vol 1. Jeff Doyle goes into good detail on the pros and cons of using next hop IP's and exit interfaces, and the appropriate situations for each.
  • johnifanx98johnifanx98 Posts: 329Member
    When you specify a next hop address, the router will recurse the routing table until it finds a connected route to get to that destination, and then uses that in the cef table (assuming you have cef enabled)

    When you specify an exit interface on a non-p2p link, it will do it's layer2 to 3 resolution for *every* address out that interface. So if you specify any type of ethernet interface as an exit interface for a route, it's going to arp for every single destination address out of that interface. Imagine if you set your default route out an ethernet interface on an internet facing router... you would arp for EVERY ip on the internet that someone tried to contact.

    Generally speaking, you should use next-hop IP's unless you have a really good reason to use interfaces.

    I'd recommend reading the chapter on static routing in Routing TCP/IP, Vol 1. Jeff Doyle goes into good detail on the pros and cons of using next hop IP's and exit interfaces, and the appropriate situations for each.

    Order placed! Thanks for pointing. BTW, should this subject be covered by certain standard? It's kinda expensive to spend $8 just to find a illustration of 3 paragraphs. Wish this CCiE book will disclose more such interesting details though I am focus on CCNA for now...
  • Forsaken_GAForsaken_GA Posts: 4,024Member
    Routing TCP/IP Vol. 1 is one of the bibles of Cisco routing. Everyone with network engineer aspirations on Cisco equipment should own (and ideally have read) a copy.
  • HeeroHeero Posts: 486Member
    It is inefficient to have to iterate through the route table. When you have CEF enabled, it will pre-compute this information and store it in CEF tables in a more efficient form for faster routing and switchigng
  • Forsaken_GAForsaken_GA Posts: 4,024Member
    Heero wrote: »
    It is inefficient to have to iterate through the route table. When you have CEF enabled, it will pre-compute this information and store it in CEF tables in a more efficient form for faster routing and switchigng

    This is true of most cisco platforms, but you can't always count on CEF being enabled. It's also irrelevant to non-Cisco platforms, so it's good to know the basics of route recursion. CEF is, essentially, a hack.
Sign In or Register to comment.