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.

Assuming a router has a built in switch which passes data packets to machines on the LAN based on the MAC address of all locally connected devices I want to know when and how (readying the packet for the internet using IP addresses) its sent to the internet. I'm making an assumption that all local options are exhausted first but I thought it might be more intelligent than that.

share|improve this question
1  
For the long and ugly detail see: serverfault.com/questions/49765/how-does-ipv4-subnetting-work –  Zoredache Jul 25 '13 at 0:05

2 Answers 2

NOTE: DNS resolution occurs before any of the below in order to determine destination IP address.

If the request IP Address is on your local LAN, your router doesn't even get involved (aside from the switch part which is a series of ethernet ports).

Your local routing table (command line route print on win, plain route on lin) shows you the routing table that the OS uses to figure out what interface to send the packet out of depending on addressing. The IP stack will then do an arp request to find the MAC for the machine on the local network and establish direct communications through the switch.

If the IP address is foreign to your local network, then the OS routing table sends it to the gateway address, which is your router and your router uses a similar routing table to forward the packet to its gateway, ad nauseum till it gets to destination.

share|improve this answer

At a very simple level, you are right.

Take Google. When you request Google.com, your router first checks its own local tables, if there is no matching table (Host / IP) then it passes it to your modem. The modem then does essentially the same thing, and sends the request to its DNS server, which might be the ISPs or a third party, this is repeated until it reaches either a router that has the correct entry or reaches the iana root servers.

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.