Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
So it will still forward the packet to eth0 and not send an ICMP destination unreachable message? –  Bruce Mar 31 '12 at 19:05
    
@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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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