Take the 2-minute tour ×

Can someone explain how IP routing works to me?

E.g. if i ping, how does each router know which way to go as shown in a trace route dump.

share|improve this question
You want someone to type out what has been explained many times? starlancs.com/EducateMe/educate_IP_stack.html snmptools.net/netbasics/layers –  d-_-b Apr 19 '10 at 4:42

2 Answers 2

up vote 8 down vote accepted

This explanation will be simplified let me know if you want more details. It's not completely accurate but it should give you a a good explanation.

It basically bubbles up. When you do ping x. If your computer doesn't have address x in it's routing table it goes to it's gateway (if you look at your routing table it will be the one that has destination default or then it will look at it's routing table to see if it has a route that matches this address or ip range if for example if it had as a route it would send it to what ever ip address it has associated with that route. If it doesn't it will do the same as your computer, send it to the default route.

For your computer for example, this will end when your ISP receives this and it will send it to what ever peer it knows has a route for this address (or is likely too, they share routing tables at that level). Then the reverse process happens, it goes down towards more specific ranges until it reaches the computer in question.

  1. your compter(no match, send to default route)
  2. your router (no match, send to default route) ->
  3. ....
  4. router X (match found for with associated address
  5. router at (match found for with associated address
  6. router at (match found for with associated address
  7. router at is directly connected to that computer(or thru a switch) and it sends it the packet because it knows it's network card mac address.

The commands route and traceroute(tracert for windows) might help make this clearer. On unix these commands have a -n option that make them show the address and not the dns name of the particular address.

using route, my default route is show do be:


the IFACE here is important because it tells the computer what network card is connected to this router which is at My computer will send all packets with unknown location through the ETH0 network card.

share|improve this answer

Each router gets an IP packet with a destination address. It will pick a next hop, based on the most specific route that matches the destination.

If we start from your computer, it will have two (there may be more, but "two" is the typical case) routes installed. One is for the LAN it's on, the other is for ("the internet", usually called the default route). If the machine you ping is not local to the LAN, the packet will be sent to the default gateway.

Then, each intermediate router, until the router that has the destination LAN attached, will do the same thing. Look up the most specific route to the destination, then send teh packet on.

The intermediate routers will, most probably, have learned of the best route using one or more routing protocols (BGP, OSPF or similar), both to lessen the administrative burden and to provide a measure of fault tolerance.

share|improve this answer

Your Answer


