If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

IP addresses

The Internet Protocol (IP) describes how two computers can communicate with each other, and it's used by every computer on the Internet.
Each computer has an IP address, just like homes and companies have mail addresses.
When a computer sends a message to another computer, it specifies the recipient's address and also makes sure to include its own address, so that the second computer can reply.

IP v4 addresses

In the IP v4 protocol, IP addresses look like this:
74.125.20.113
🔍Try visiting that IP in your browser. Where does it go?
Each IP address is split into 4 numbers, and each number can range from 0 to 255:
[0-255].[0-255].[0-255].[0-255]
We write those numbers in decimal, but to the computer, they're represented with bits, like so:
01010101 01010101 01010101 01010101
Each number can represent 28 values, thanks to the 8 bits. That's also why we often call them "octets."
Overall, that's 232 possible values: 4,294,967,296 possible IPv4 addresses.
That's a lot! But remember, in the beginning, we said there are more than 4 billion devices connected to the Internet? Well, we're reaching the limit of possible IP addresses. It's time for plan B.

IP v6 addresses

Back when they invented the Internet, they didn't anticipate how popular it'd become and they thought that 4 billion would be plenty.
That's what led to the IPv6 protocol, a new addressing scheme. Here's an IPv6 address:
2001:0db8:0000:0042:0000:8a2e:0370:7334
Notice the letters in those numbers, like d and b in 0db8? Those are hexadecimal numbers, which means that the IPv6 address is much longer than it looks. Let's do some math to see exactly how much longer.
There are 8 hexadecimal numbers, and each number is 4 digits long. The highest value for each number is FFFF, since F is the highest digit in hexadecimal. Thus, the highest address would look like:
FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
What's FFFF in decimal?
FFFF
163162161160
4096256161
Each F represents 15 in decimal, so that's (15×4096)+(15×256)+(15×16)+(15×1): a grand total of 65,535.
We can also calculate that based on the bit representation of FFFF. Each hexadecimal digit F corresponds to 1111 in binary, so that results in these 16 bits:
1111 1111 1111 1111
As we discuss in Binary numbers, the highest number that can be represented by n binary digits is 2n1. That means the binary number above is 2161, which once again equals 65,535.
Each 4-digit hexadecimal number can range between 0 and 65,535, so each number can represent 65,536 unique values—and there are 8 of them!
In total, each IP v6 address is represented by 128 bits, so there are 2128 possible IP v6 addresses. That's 340 undecillion:
340,282,366,920,938,000,000,000,000,000,000,000,000
🤔 Imagine a world where we have that many Internet connected devices. What does that look like? How could that much Internet make the world better?

Hierarchical addressing

Many addressing schemes are hierarchical, like phone numbers:
+1 (541) 754-3010
We can break that into 4 parts:
+15417543010
Country codeArea codeLocal exchangeSpecific phone
The hierarchy makes it easier for the telephone system to efficiently send calls to the right lines.
IP addresses are also hierarchical. The first sequence of bits identifies the network, and the final bits identify the individual node in the network.
Consider this IP address:
24.147.242.217
We can break that into 2 parts:
24.147242.217
Comcast networkMy home network
Network administrators can break IP addresses into further subnets (subnetworks) as needed, for easier routing.
Starting with this IP address:
141.213.127.13
That could break down into 3 parts:
141.21312713
UMich networkMedicine schoolLab computer
In actuality, addresses are typically split in the middle of the octets. The first 16 bits might route to all of UMich, the next 2 bits route to a specific UMich school, and the final 14 bits route to individual computers.
IP addresses use this hierarchical addressing scheme to make routing messages easier from place to place. Once a message gets to the network, then the network can take care of sending it to the individual node.

🔍 What's your IP address?

One way to find out your computer's IP address is by searching Google for "IP address". Google knows your IP address, since your computer sends a message to the Google computers as soon as it loads google.com.
Your IP address might be different tomorrow than it is today. Each ISP has a range of addresses they can assign, and they might give you a different one of those addresses each time they see your computer pop up on the network. That's called a "dynamic" IP address.
Switching to a different Wi-Fi network will definitely give you a new IP address, since each Wi-Fi provider has its own range of addresses that it can give out.
Computers that act as servers, like the computers that power Google.com, often have "static" IP addresses. That makes it easier for computers to quickly send search requests to the Google servers. If you tried out the IP address above, you hopefully found yourself on the Google homepage.
Check your understanding
Identify whether each address below is IP v4, IP v6, or invalid:
IP addressAddress type?
119.67.44.86
94.49.190.138
258.151.50.253
e0f8:af58:eee6:52b
d938:2da7:b596:6d34:3970:6789:c941:2340
d938:2da7:b596:6d3:3970:6789

Want to join the conversation?

  • duskpin sapling style avatar for user Weather
    Is it possible for one computer to have the same IP address as another? Considering there are so many devices that have needed to be assigned an address, and also that there are probably people who want to run a server with the same address as another one for malicious purposes, how could this not happen?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • male robot hal style avatar for user MacKenzie
      It is possible for two hosts to have the same IP address on a LAN - this is known as IP conflict, and packets will not be routed to the correct host. For malicious purposes, this would be IP spoofing, and is usually used to step into an existing session and either inject data or instructions, or extract valuable information.

      As far as running a server that looks like a legitimate server - most bad actors do not use the same public facing IP address for their false server. Backbone DNS services are very well protected and hard to compromise. Instead, they will use URLs that look similar and rely on inattentive humans to miss misspellings, or take advantage of the inability of humans to distinguish between character sets that contain the same letters (ACII and UNICODE).

      This is actually part of why DNS or name servers and routers are attractive targets to hit, as you can direct traffic however you like if you compromise one.
      (7 votes)
  • duskpin ultimate style avatar for user 暗枕   。。 KuraMakura
    Would we really need 340 undecillion different IP addresses?
    Having that many seems kind of silly.
    (3 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user clearthecity
      For practical purposes, no. But the number of available IP addresses goes up exponentially for each bit added. (If it were 2^33 bits long, there would be more than 8 billion addresses, but the number of bits in a block would be inconsistent, slowing down various calculations.) Another consideration is that the number of internet-enabled devices is growing. Now, in addition to PCs, smartphones, and servers, we have "smart" coffee machines, alarms, cars, light bulbs... all requesting IP addresses, and many of them are active 24/7. So the designers of IPv6 were playing it safe.
      (10 votes)
  • duskpin ultimate style avatar for user Allison.Browne
    How are they going about changing all the IP addresses? Are they able to change the address without stopping the website or changing anything?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • duskpin tree style avatar for user Fern
    Why is IPv6 called IPv6? Why not IPv5 or IPv8?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • hopper jumping style avatar for user pamela ❤
      From the author:6 is the version of the protocol, and is specified in the packets. There was an IP version 5, but the proposal was never officially adopted. It contained ideas about improving the streaming of audio and video data. However, it still used IP v4 addressing. People soon realized the dire need for a larger address space, abandoned IP v5, and went to work on IP v6 instead. For more details, search the internet for "IP v5".
      (3 votes)
  • starky sapling style avatar for user Eveline Gomes
    I can't understand this part of the explanation... I'm stuck here :(

    "In actuality, addresses are typically split in the middle of the octets. The first 16 bits might route to all of UMich, the next 2 bits route to a specific UMich school, and the final 14 bits route to individual computers."

    What I understand of IPv4 is that they're divided into 8 bits each value. So how come the IP address be divided into 16 bits, 2 bits (?) and then 14 bits (?). I'm really confused here.
    (2 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Abhishek Shah
      I think I understand your confusion. You are correct in that IPv4 32-bit addresses are divided into octets (8 bits). This is how computers interpret these bits.

      However, humans do not have to use this same interpretation. We can assign a different meaning to the 32-bit address. In the example, we (humans) can interpret the 32 bits as grouped into 16, 2, and 14 bits. Each grouping can mean something different. In the example, the first grouping refers to UMich, the second grouping to a specific UMich school, and the third to a particular computer.

      As a concrete example, take 255.255.63.255. The computer representation is (11111111 . 11111111 . 00111111 . 11111111). We humans can view this like the following: (11111111 . 11111111) . (00)(111111 . 11111111), where (11111111 . 11111111) is the ID of UMich, (00) is the ID of the specific UMich school, and (111111 . 11111111) is the ID of the computer.

      In sum, it's a bit like how a computer could interpret 2 + 2 as addition of numbers, whereas we humans could interpret it as meaning the addition of dollars or calories.
      (4 votes)
  • duskpin ultimate style avatar for user User Name
    Is there a way to find my IP address on the terminal? ifconfig?
    (1 vote)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Chris Ricciardi
    Why 65,535 and not 65,536 possibilities for each part of the 8 hex IPv6 address? A four digit hex number should have 16^4 possible values, shouldn't it? The text even uses 2^16 as an alternative calculation and that should equal 65,536.
    (2 votes)
    Default Khan Academy avatar avatar for user
  • male robot hal style avatar for user Collin Morudi
    So far I have only seen IPv4 addresses, so does this mean that IPv6 is not yet used or there exist devices out there that are addressed using IPv6?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Martin
      No, the IPv6 switch is well underway and many have done the switch the IPv4 is easier to read so that might be why you see it more often.
      Here the IP of a google DNS server

      2001 :4860 : 4860 : 0 : 0 : 0 : 0 : 8888

      There should be no empty spaces between the numbers and the colons, but the forum converts numbers next to colons as something else.
      (2 votes)
  • aqualine ultimate style avatar for user elikemcan
    How am I supposed to differentiate between an IPv4 address and an IPv6 address? And how am I supposed to tell if it's valid or not? I've stuck!
    (1 vote)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Martin
      An IPv4 adress is made up of four units each containing a number between 0 and 255 (0 - FF in hexadecimal) and seperated by a dot

      So 111.111.111.111 would be valid v4
      343.111.111.111 not and 22.22.1 neither.


      An IPv6 adress is made up of eight units each containing a hexadecminal number between 0 and FFFF and seperated by colons

      FF22:FFFF.FFFF:/FFFF:/0D00:/1111:/0024:/4897

      would be a valid Ipv6 adress.

      The slashes shouldn't be in the adress I just added them because of the forum formatting.
      (1 vote)
  • aqualine ultimate style avatar for user Eishah Armaghan
    How can I know what is my IP address?
    (1 vote)
    Default Khan Academy avatar avatar for user