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 address hierarchy

The Internet Protocol (IP) describes the use of IP addresses to identify Internet-connected devices. IP addresses have a hierarchy that makes it easier to route data around the Internet.
Many addressing schemes are hierarchical. Consider a US phone number:
+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.

IPv4 address hierarchy

Both IPv4 and IPv6 addresses are hierarchical. For simplicity, let's examine the hierarchy of IP v4 addresses.
Consider this IP address:
24.147.242.217
The first sequence of bits identifies the network and the final bits identify the individual node in the network.
That IP address could break down into these 2 parts:
24.147242.217
Comcast networkA home computer
The first two octets (16 bits) identifies a network administered by the Comcast (an Internet Service Provider). The last two octets (the final 16 bits) identifies a home computer on that Comcast network.
An illustration of the IP address space. Multiple networks are shown with different 2-octet strings above them. The network with "24.147" is highlighted. Within that network, multiple computers are shown with different 2-octet strings. The computer with "242.217" is highlighted.
An IP address identifies a network and then a node within that network.
If the last two octets were different, then the IP address would point at a different computer on the Comcast network. If the first two octets were different, then the IP address might belong to a completely different network administrator.
The Internet Protocol uses this hierarchical addressing scheme to make it easier to route messages from source to destination. Once a message arrives at the network, a network router can take care of sending it to the individual node. The next lesson on routing dives into more details on how that works.

Subnets

Network administrators can break IP addresses into further subnetworks (subnets) as needed.
Starting with this IP address:
141.213.127.13
That could break down into 3 parts:
141.21312713
UMich networkMedicine departmentLab computer
The first two octets identify the entire network for the University of Michigan, the third octet identifies the UMich Medicine department's network, and the fourth octet identifies an individual lab computer in that department's network.
Adding further levels to the address hierarchy can improve the efficiency of routing within the network.
Check your understanding
According to the breakdown above, which of these IP addresses identify computing devices in the UMich Medicine department's network?
Choose 1 answer:

Splitting octets

In actuality, IP addresses are often split in the middle of the octets.
To understand how that works, let's represent the previous IP address in binary instead:
14121312713
10001101110101010111111100001101
All together, that translates into these 32 bits:
10001101110101010111111100001101
The first 16 bits could route to all of UMich, the next 2 bits could route to a specific UMich department, and the final 14 bits could route to individual computers.
10001101110101010111111100001101
UMich networkMedicine departmentLab computer
This hierarchy gives UMich the ability to differentiate between 22 (4) departments and 214 (16,384) computers within each department.
Splitting octets might seem confusing at first, but computers store the IP addresses as binary anyways, so it is all the same to them.
As we've just seen, the ability to create hierarchical levels at any point in the IP address allows for greater flexibility in the size of each level of the hierarchy.
Check your understanding
If the UMich network instead used 3 bits to identify a department network, how many departments could they differentiate between?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3/5
  • a simplified improper fraction, like 7/4
  • a mixed number, like 1 3/4
  • an exact decimal, like 0.75
  • a multiple of pi, like 12 pi or 2/3 pi


🙋🏽🙋🏻‍♀️🙋🏿‍♂️Do you have any questions about this topic? We'd love to answer—just ask in the questions area below!

Want to join the conversation?

  • duskpin ultimate style avatar for user muhammadmlahim12
    In the last " CHECK YOUR UNDERSTANDING " (Q #02):

    If the UMich network uses 5 bits to identify the department networks, then how that leaves only 11 bits to identify individual computers within each network ? As 8 bits are used by UMich Network.

    UMich Network(8_bits), Department Network(5_bits), Individual Computers(3_bits)

    Waiting For Reply
    (6 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Martin
      An IPv4 address is made out of 32 bits.
      According to the example in the article the first 16 bits route all to the UMich network. That means you have 16 bits left over to identify different clients in the network itself.
      In this case, 5 are used to identify department networks in the UMich network leaving 11 to identify individual computers.
      (26 votes)
  • sneak peak green style avatar for user Malycia | Peace
    Why is it called IPv6 if there are 8 groups of 4 numbers?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Martin
      IPv6 is the version number so it's Internet Protocol version 6. So the number has nothing to do with the number of bits in the address.

      So the question is what happend to IPv5?
      IPv5 was assigned to an experimental streaming protocoll, that was never made public. So it was decided to just jump to IPv6.
      Today something like that probably wouldn't happen, because the IAAA (the internet assigned numbers authority) has matured a lot and as such experimental protocols probably wouldn't be assigned an actual version number.

      That having been said at the moment the version number 0 - 9 and 15 are reserved. So if we would need a new internet protocol tommorrow we'd have to call it the IPv10. But that shouldn't happen because the address space of IPv6 is so large.
      (22 votes)
  • blobby blue style avatar for user Prof. Parmigiano Reggiano
    So does my IP address change when I take my laptop to a café or coworking space?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • leaf blue style avatar for user Hunter R. Shaw
      There are two types of IP addresses. Within a LAN, each NIC can obtain one IP address. Now, when you're connected to the internet through a router, the router's IP address is used publicly. This is why IP bans will hit your whole network. To demonstrate this, go into Command Prompt, and type ipconfig. This should show you your IP address as far as your LAN is concerned. Then, go online and check what the internet thinks about your IP address.

      Both of these change when you connect to a new network. It's very likely though that your home LAN IP will be maintained once you return home, and the router IP will be maintained unless your ISP gives you a new one.
      (8 votes)
  • blobby green style avatar for user shivuke05
    This lesson explains the IP address hierarchy regarding IPv4 addresses, but how does it work with the more current and popular IPv6 addresses?
    (5 votes)
    Default Khan Academy avatar avatar for user
  • leaf red style avatar for user layaz7717
    Does an IP address reveal your location? In other words, is it based on your location?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • sneak peak green style avatar for user Ray
    Talking about IP Addresses, what are VPNs for?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Shane McGookey
      A VPN (Virtual Private Network) is an encrypted connection over the Internet from a device to a network. The encrypted connection between your device and the network of interest is known as a "tunnel."

      There are a number of VPN use cases. One common use case (I would encourage you to explore other use cases) is remote work. When an employee is working remotely, it is common for the employee to use a VPN to connect to the corporate network. Encrypting communication between the employee's device and the corporate network helps to keep sensitive data secure.
      (7 votes)
  • blobby green style avatar for user TaccarriaB
    Why is ir called IPv6 if there are 8 groups of 4 numbers?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user AV
    Who (or which devices) on the internet, store the IP addresses ?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Siham Bch
    Comcost.. what does it mean pls ?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Kendra Austin
    Under Splitting Octets, it states in one of the examples: "The first 16 bits could route to all of UMich, the next 2 bits could route to a specific UMich department, and the final 14 bits could route to individual computers." Do those bits actually "taper off" as they hit various routers and switches, or do those bits still stay part of the IP packet capsule until it reaches the destination computer? Maybe they were just using that to conceptualize it and I'm overthinking it.
    (3 votes)
    Default Khan Academy avatar avatar for user