Networking – How to avoid routing loops because of router default route entry

ipnetworkingrouting

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?

Best Answer

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.

Related Question