7

Inside a router network it's easy to route all the packages. The router knows all the clients. However, on the internet, there are so many IP addresses.

I send a packet from my computer to the IP 1.2.3.4. It reaches the router. It checks it against its rules and sees that this isn't on the local network. Then it routes it through the Ethernet port. What happens next? Then it reaches the server, and the server sends a packet in return. Finally it reaches the router. How does the router know which computer (mine) to send it to?

1 Answer 1

8

In a nut-shell, when a router doesn't know how to route a packet it'll send the packet to the default gateway/the next "hop".

Basically, when your router can't find a valid rules (or more formally, it's route table) it will send the packet to the default gateway, which will typically send it upstream to your ISP.

Once the packet arrives at your ISP's routers, much like your own router, they will have their own route tables. But this time they'll be more detailed. Knowing about other customers and other ISP's.

This will continue on until the final router that has the final destination rule attached to it, sending it onto the specific computer/Interface.

All along this way, the packet includes source information indicating where the original packet came from. Your router (likely, with NAT) would had converted this source information from your local machine's internal only IP address (e.g. 192.168.1.25) to your WAN IP address given to you by your ISP (e.g. 121.147.148.55) and this WAN IP will be what's contained within the packet's source information.

Thus, all the upstream routers can simply perform the same routing as above, but in reverse to send your packet back to you. However, once it reaches your router. Your router has it's own special rules to know that that certain packet should be forwarded back to your local machine with it's internal only IP address. This is called Network Address Translation.

7
  • Aha! So this system implies that a bulk of IP addresses are restricted to a specific geographic area (given that the internet is set up to maximize it's speed)? And the ISP then knows which physical cable has the shortest distance to the next node? It tables tells it that the requested IP is in the US. Then it sends the request off in the cable with the shortest physical distance to the US? Feb 1, 2014 at 21:35
  • 2
    @FriendofKim Yes, your ISP will know which physical cable to send your request based off their routing tables (and this repeats for your ISP's ISP, and their ISP and so on). However this might not necessarily be the physically "shortest" path. For the most part, route tables are crafted manually and network engineers for major ISP's will factor in a lot of variables such as cost of the connection, available bandwidth, how stable it is and so on.
    – Michael P
    Feb 1, 2014 at 21:45
  • So the factors tries to determine the shortest path measured in time? Does this mean that if an ISP starts handing out "random" IPs it hasn't bought, the request will never reach the destination? Does this mean that companies like ARIN and RIPE hands out IPs according to physical location of the buyers servers? Feb 1, 2014 at 21:48
  • 1
    IP hijacking on Wikipedia will be good reading for this question. Basically, if an ISP advertises an IP address it doesn't own then it can route that stolen IP wherever it wants, even to a computer serving requests. However, this would be very easily caught so it rarely only ever happens rarely, and generally on mistake and is detected and resolved fairly quickly. Basically, the Internet's routing table is a collaborative effort, at the end of the day big ISP's collaborate between each other with who owns what via companies such as ARIN and RIPE.
    – Michael P
    Feb 1, 2014 at 21:54
  • I understand. But if someone hijacked an IP, how would my computer be able to contact it? If the hijacked IP is 1.2.3.4, and 1.2.x.x is in Europe, and the server of 1.2.3.4 is in the US, wouldn't the request just stop in Europe without finding the server? Feb 1, 2014 at 22:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .