Say my router has two interfaces (eth0 and eth1). The default entry in the routing table uses eth0. Now if the router gets a packet on eth0 and the dst IP does not match any entry in routing table, it will send the packet back on the default route. This will lead to a routing loop. How does a router avoid this? Does it realize this and send a ICMP destination unreachable (type 3, code 0) message. In general does a router ever forward a packet to the same interface on which it was received?


IP datagrams have a "Time To Live" (TTL) value in the IP header. Each time a router forwards a datagram, it decrements (subtracts 1 from) the TTL. When the TTL reaches zero, the router drops (deletes, does not forward) the datagram, and sends back an ICMP "Destination Unreachable, TTL Exceeded" message.

Also, when your router got a packet from a host on eth0 that would have been better delivered to another host or via another router that was also on the data-link layer network (in this case, the Ethernet LAN) out eth0, it could send an ICMP Redirect message to inform the local host that sent that packet that it should really have sent it directly to that other host or router on the same Ethernet LAN.

Overall, routing loops are avoided through good network design, and through using route advertisement protocols and route table maintenance procedures that avoid loops.

  • 1
    So it will still forward the packet to eth0 and not send an ICMP destination unreachable message? – Bruce Mar 31 '12 at 19:05
  • 1
    @Bruce Yes, in my experience, it will forward it back to the default route after decrementing the TTL, which means it'll keep going through the loop until the TTL his zero. Then again, I mostly deal with simple consumer home gateway routers, so maybe enterprise-grade gear is smarter about it. – Spiff Mar 31 '12 at 19:08

First, ALL routers by definition have multiple interfaces.

Second, the router should not normally even receive something it has to spit back out on the same interface.

If you are sending traffic to a router that it shouldn't be routing, something is not setup correctly in that host (maybe DHCP handed out the wrong default gateway, IP address/network mask not set correctly, etc.)

As @Spiff said this is why there's a TTL.

Routing loops are typically a bigger problem when you have more than two interfaces and more than one router in a subnet. Routing protocols such as RIP, IGRP, EIGRP, OSPF, and BGP are used between routers to work things out such as who is routing for a subnet, who's the backup, and to track when routers are no longer reachable.

  • 1
    "ALL routers by definition have multiple interfaces". Sure, except routers on a stick. – Navin Jul 16 '16 at 2:27
  • 1
    That's a good point. I guess really a router always has a connection to multiple distinct networks, but they can be the same interface. en.wikipedia.org/wiki/One-armed_router – LawrenceC Jul 16 '16 at 4:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.