3

Complete newbie question:

Say for example the address: 8.8.8.8
How does the computer know that this address is on the internet, not the local network?

Could a device on the local network have the address 8.8.8.8 too?

8

Your computer knows that 8.8.8.8 is not on your local network, because that address is not part of the subnetwork that your computer interface card is configured for.

Let's say your PC has an ethernet adapter configured as 192.168.0.100 255.255.255.0. When your computer wants to forward a packet to 8.8.8.8, it looks in its routing table to see which interface it should use. The routing table lists all the networks your computer knows about. On a typical PC, you will have two entries in the routing table:

  • Your local network, 192.168.0.0 255.255.255.0
  • A default route (listed as 0.0.0.0 0.0.0.0)

First, your computer applies the subnet mask of each entry in the routing table to see if the destination matches any of the networks. So it applies the mask 255.255.255.0 to 8.8.8.8 and gets the network 8.8.8.0. That doesn't match the first entry.

It also applies the mask from the default route 0.0.0.0, and gets the network 0.0.0.0. That does match the entry 0.0.0.0 so the computer looks to see where it should forward that packet. The entry lists a next-hop address (also called a default gateway), so your computer creates an ethernet packet with the following information:

  • Source IP address: the IP address of your computer interface>
  • Source MAC address: the MAC address of your interface
  • Destination IP: 8.8.8.8
  • Destination MAC: the MAC address of the default gateway

It then forwards it to the default gateway, which forwards it on to its destination.

On a Windows PC, you can see your routing table by typing "route print" at a command prompt.

There is no real distinction between "the Internet" and your local network, other than 8.8.8.8 is not your directly connected network.

  • To be more precise, the netmask is a 32 bit binary number used to specify your local network. It is always contiguous (some version of WinNT permitted non-contiguous netmask... Hilarity ensued when troubleshooting) and is represented the same way than an IP address (Dotted Quads) The pc does a bitwise AND to validate if the destination is on the same network (if so, a simple ARP is done to get the IP) if not, the packet goes to the Default Gateway (an ARP is done for that one if not in cache, then frame is sent directly to the GW MAC) – Remi Letourneau Feb 12 '14 at 14:43
1

NAT (Network address translation) translates your local IP address from your private network(LAN) to a public IP address usually provided by your ISP to connect to the internet (WAN). Your private IP's are not routable IPs meaning they can't route through the internet to reach its destination network, while Public IPs are routable IPs that travel accross the internet through multiple WANs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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