Here's a VERY brief outline of how IP addressing works in this situation:
You have your home computer, it has a network interface (Ethernet port or Wi-Fi card), and each of these have unique MAC addresses which identify them globally.
Network interfaces are given IP addresses by your router/modem/switch/access point. Your access point (AP) is part of or connected to a modem/router/switch which gives the AP an IP address. This is how things look so far:
Your computer (IP)->Access Point(IP)->CableModem(IP)
Here is an example of what those IP addresses might be. In the example, the 4th octet (the last number of each set) determines your device's IP address, the 3 to the left of them determine the devices network.
192.168.1.50---------->192.168.1.25-------->192.168.1.1
Essentially, in this example, the modem creates a network called 192.168.1 All devices on the network are given a different x value (1-255), the last digit.
Here's an important distinction. There are two types of IPv4 IP addresses, Public and Private. Public IP addresses are the ones you see on the Internet (if you ping google.com you'll get a public IP address). Inside of a network you typically have a Private IP setup (192.168.x.x and 172.x.x.x and 10.x.x.x - they are all IP addresses that do not exist on web servers in the internet; they are reserved for local networks).
Typically, your home network has a gateway which is something like x.x.x.1 (192.168.1.1, 10.1.1.1, for instance). This means that they are not accessible from the outside world, they are meant to be INSIDE your network.
How do internal network devices get on the Internet then?
If you go to http://www.whatismyip.com/ you'll see an IP address listed which is not your computer, your AP, or your modem/router. This is your Public IP address.
Typically, your modem/router has two functions. 1) Receive an IP address from the outside world and talk to your ISP's network with that address 2) Create an internal network and let them talk through its external interface.
So here's, effectively what your modem does:
Public IP (cable jack) <----> [Modem|Ext IP address/Int LAN] ---> Ethernet ports <---> [computers]
The modem bridges the public Internet to your network. Requests from your internal network get sent to your modem which forwards them to the Internet. This way only one public IP address is needed for ALL of your devices to talk to the Internet.
On the Internet side of the modem you have an IP address assigned by your ISP which is the one www.whatismyip.com shows you. This is put on the interface of your modem which is attached to your cable/DSL/T-1 line. The other side of the modem/router (where you plug in your access point, switch, or computers) is given an IP address you can configure. The way people are able to have servers visible to the public is that they can tell the modem things like this: "When a request comes to our PUBLIC IP address asking for a resource, connect that traffic to an INTERNAL IP ADDRESS OR RESOURCE"
When you send a message, your computer's IP address basically becomes 'encapsulated' within various 'headers' on your data. Ultimately, the computers seeing your traffic see your external IP address from your modem and not your physical computers internal IP address. More data is sent containing MAC addresses and things like that but, essentially one public IP address can represent an entire network of devices behind it.
More information can be found in What is an IP address? (or all over the Internet :)
NAT is the process by which your router translates the internal addresses to your public address and your public incoming traffic to the correct internal IP address.
There's a lot more to it, but that should be the general idea. For more, look in to the OSI Model, IP "Sockets", and another good article is How Does the Internet Work?.
7
possible duplicate of How does the router know which device to send packets to?, How does Network Address Translation (NAT) works on a home router?
– Ƭᴇcʜιᴇ007 – 2014-08-21T16:06:13.7931This kind of question reaffirms my belief that IPv6 is easier to learn than IPv4. – kasperd – 2014-08-21T18:15:55.587
1@kasperd be that the case or not, the fact that there's 2, very different protocols, used for the same goal, makes it confusing for everyone!
We really need IPv6 adoption fast. – Cruncher – 2014-08-21T19:53:20.010
1
Your two computers are on a LAN, they cannot have the same IP on that LAN. Your router is also part of the LAN with a LAN address. It is also part of the ISP network with the IP provided by the ISP (a single public IP that is different from the LAN ones). Your router knows how to relay packets in and out between LAN and ISP network, by translating LAN addresses into public ports and vice-versa. This conversion is known under NAT acronym. NAT allows to use a single public address for multiple LAN computers.
– mins – 2014-08-21T21:26:10.1604IP addressesing, ARP tables, NAT, DHCP, and routing fill entire books. This question is entirely too broad to be answerable in its current format. – CodeGnome – 2014-08-22T12:09:07.003
Yes, both computers will have the same external IP address. Your router will adjust the data you send to a webserver, adding a unique identifier, so that I can send incoming replies, to that unique ID, to your computer (see NAT). – BlueCacti – 2014-08-23T23:47:55.653
The computers have different IP addresses from each other, but whenever you access the outside Internet, the router changes the request so it looks like it came from the router itself. The router remembers which computer the request came from so it can send the response back to that computer. To any server on the Internet, it looks like the router is the only thing sending packets. This is NAT. – user253751 – 2014-08-24T06:00:43.430