71

Do two computers connected on the same Wi-Fi have the same IP address (for example, my dad's computer and my computer, at home)?

If so, how does the outside world distinguishes one computer with the other? (for example, when a server wants to send us back some data).

7
  • 7
  • 1
    This kind of question reaffirms my belief that IPv6 is easier to learn than IPv4.
    – kasperd
    Aug 21, 2014 at 18:15
  • 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
    Aug 21, 2014 at 19:53
  • 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
    Aug 21, 2014 at 21:26
  • 4
    IP addressesing, ARP tables, NAT, DHCP, and routing fill entire books. This question is entirely too broad to be answerable in its current format.
    – CodeGnome
    Aug 22, 2014 at 12:09

8 Answers 8

94

You're both seen as having the same IP address externally.

Your router will relay requests to the originating computer. The procedure used for this is network address translation (NAT).

One of the ways computers on the same network get distinguished in communication with the same public server is by assigning them by the router different port numbers in the communication. Their public IP address is the same, but the port number part is not. From the article:

To avoid ambiguity in how to translate returned packets, further modifications to the packets are required. The vast bulk of Internet traffic is TCP and UDP packets, and for these protocols the port numbers are changed so that the combination of IP and port information on the returned packet can be unambiguously mapped to the corresponding private address and port information.

However, if you were to try to communicate to your father's computer, you will be using your internal addresses.

These use a custom range intended only for internal use: private address range.

Computerphile has a YouTube video on this exact subject: Network Address Translation (video).

10
  • 7
    it is possible that the wirless router doesn't do NAT, for example a internal accesspoint in a business office where the NAT box is elsewhere Aug 21, 2014 at 20:59
  • 8
    Which is true, however I honestly doubt it's the case for this guys home setup :)
    – Reaces
    Aug 22, 2014 at 7:12
  • 5
    @Anixx From inside the network that's how it would appear. Go to whatismyip.com from each device and check your external address using that.
    – Daenyth
    Aug 22, 2014 at 16:21
  • 3
    This answer could be improved by adding notes about AP vs NAT modes and how to check what state your local network is in.
    – Daenyth
    Aug 22, 2014 at 17:49
  • 4
    @Anixx, that sounds like a fairly poor setup: you cannot use a 6th device on your wifi and, worse, every device you use is wide open on the internet. Aug 23, 2014 at 13:27
26

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?.

4
  • 2
    so is it the MAC address encapsulated in incoming packets that tell the NAT to redirect to my computer / my dad's ?
    – Thomas
    Aug 22, 2014 at 7:20
  • 4
    no MAC is lower level than IP, and it doesn't leave the network (messages from outside use your router's MAC), a NAT box essentially is a MitM that looks at each TCP connection that an internal pc wants to make and makes its own connection and forwards its incoming messages. Aug 22, 2014 at 7:35
  • 1
    so in the packets from the outside server to me, there is something that helped the modem know that it had to be addressed to me and not to my dad. what is it ?
    – Thomas
    Aug 22, 2014 at 15:03
15

Any of these topics could be examined in far greater detail.

You and your dad have the same external address, but different internal addresses.

External IP addresses are like a street address. The whole world can find you using that address.

Internal IP addresses are like rooms in a house. Only someone in a house can use directions to find the specified room. In your case, only someone connected to the same wifi can see your internal IP address.

Using default settings, a wifi network will have a single external IP address. When the mailman brings mail to your house, someone has to get it from the mailbox and distribute it to who it belongs to. Each wifi network has a router, which acts like your personal doorman. The router "collects the mail" and gives it to you only if it is addressed to you. Mail addressed to your dad goes to him.

The outside world only sees one address, your external address. Computers and other devices inside the network only see the inside. The router is the only thing that sees both sides.

To see this in action, go to Google and type "what is my ip?". This will be your external (or public) address. Next, find your internal address. In Windows, open a command prompt. Then type: ipconfig and hit enter. You will see a whole bunch of stuff similar to this. The picture highlights your internal IP address. Running this command on your dad's computer would get a different number, but googling your IP address from his computer would get the same number.

For your curiosity, the default gateway listed is the internal IP address of your router. If you are using a Mac, google "find your IP on mac" for directions to find your internal IP.

6
  • We use almost this same house analogy where I work to teach networking basics to some of our students that don't quite get how routing works. Works every time.
    – Sarge
    Aug 21, 2014 at 22:32
  • so in a packet sent on the internet, does the router encapsulate the internal ip address (or another internal id) ?
    – Thomas
    Aug 22, 2014 at 7:30
  • @Sarge I've never heard the analogy before. What differences are there between my version and what you use for students? I might nab better parts from your version for future use.
    – Taejang
    Aug 22, 2014 at 14:15
  • @Thomas Routers almost always use the internal IP address inside a network. That said, routers can be configured to use MAC addresses, names that correspond to a DNS list stored on a server, or even other ids manually stored in the router's config. Such methods are just about exclusive to businesses, universities, and other large networks. Routers can also be configured to route things to other routers to divide the work in large networks; this is usually done with router IP addresses (which are internal).
    – Taejang
    Aug 22, 2014 at 14:24
  • 1
    @Dan, where you use house, we sometimes use apartment building, office building or even show the progression of mailing a letter from one state to another and how it moves through the US Postal System.
    – Sarge
    Aug 22, 2014 at 23:40
6

Do two computers connected on the same Wi-Fi have the same IP address (for example, my dad's computer and my computer, at home)?

Answer: externally yes, within your network no

If so, how does the outside world distinguishes one computer with the other? (for example, when a server wants to send us back some data)

Answer: The outside world does not distinguish, it will communicate to/from your external IP address. The router's job is to distinguish. Each device on your Wi-Fi will have a unique local IP address.

2

This depends on whether the router in in the access point mode. If so the computers will have different addresses, otherwise there would be NAT and only one IP address.

2

No. Two computers with the same IP address will cause issues. They will have similar addresses, but not the same. You will have the same "external" address, however, and you can find this by typing in "What is my IP" into Google. All the traffic on your network will appear to come from this IP address, regardless if you have one machine on your home network, or your computer, your dad's computer, your phone, tablet, smart TV, smart fridge, smart dishwasher, etc.

1

The external IP address is assigned by your ISP to your router which in turn assigns different internal IP addresses to all devices in the network. The outside world can only see your external IP address. In short, it cannot distinguish between your dad's computer and yours.

When a server sends you some data, it will be transmitted only to your device by your router (because you requested it) and not your dad's. (Please correct me if I'm wrong.)

1
  • 2
    Can you expand? This answer is quite low in quality, especially given the other answers here. Feel free to edit to give more information, but make sure you don't duplicate information. Aug 21, 2014 at 16:32
0

It was curious how nobody thought about same (internal/local) ip address for both computers connected to the same AP. I found this when looking on why all the devices at home connected to one XFINITY AP have the same IP. some answers I have found talk about VLANs [A combination of vlans, tagging and mac/ip ]

You must log in to answer this question.

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