Achievable logoAchievable logo
CCNA
Sign in
Sign up
Purchase
Textbook
Practice exams
Support
How it works
Exam catalog
Mountain with a flag at the peak
Textbook
Introduction
1. Introduction to networking
2. Administering Ethernet LANs
3. IP connectivity
3.1 Understanding IP addresses
3.2 Calculating networks and hosts
3.3 Routers and IPv4 routing fundamentals
3.4 Static routing
3.5 Static vs. dynamic routing and OSPF fundamentals
3.6 Router redundancy in an Ethernet LAN using First Hop Redundancy Protocols (FHRPs)
3.7 Configuring Cisco Routers
4. Network services
5. IPv6
6. Wireless networking
7. Network management and administering network devices
8. Network security fundamentals
9. Network automation and programmability
Wrapping up
Achievable logoAchievable logo
3.2 Calculating networks and hosts
Achievable CCNA
3. IP connectivity
Our CCNA course is currently in development and is a work-in-progress.

Calculating networks and hosts

8 min read
Font
Discuss
Share
Feedback

In this chapter, you’ll learn how to calculate the size of IPv4 networks and how many IP addresses they can hold. This technique is called subnetting.

Subnetting lets you create multiple smaller IP networks from one larger network by extending the subnet mask (in other words, increasing the prefix length). Practically, that means you borrow host bits and turn them into network bits by changing bits in the subnet mask from 0 to 1. After you do that, the point where the 1s stop (and the 0s begin) becomes the new network/host boundary.

Please review Chapter 3.1.2 IPv4 Network Addresses vs. Host Addresses if you’re having trouble following the paragraph above.

Calculating the amount of networks

Let’s walk through an example.

Say you have one IP network, 192.168.1.0/24, and you need to split it into two separate IP networks. You can do that by changing (extending) the original subnet mask.

The subnet mask /24 is written in CIDR notation.

What would be the dotted-decimal representation of this subnet mask?

(spoiler)

255.255.255.0

To divide a network into multiple networks, you borrow host bits from the original subnet mask and convert them into network bits. The key question is: how many host bits do you need to borrow to create the number of networks you want?

You can calculate that with this formula:

2n

This means 2 to the power of “n”, where “n” is the number of host bits you borrow (and turn into network bits). The result is the number of networks you can create with the new subnet mask.

For example, if you borrow 1 host bit, then n=1:

21=2

So, borrowing 1 host bit from a /24 (making it a /25) gives you 2 networks.

Next, let’s look at the host bits available in the original subnet mask. To see the bits clearly, convert the subnet mask to binary.

(Image 136)

Image Title - Subnet Mask 255.255.255.0 with the Binary bits underneath

Now, here’s what the subnet mask looks like after converting one host bit into a network bit:

(Image 137)

Image Title - Borrowing a Host bit from the 255.255.255.0 Subnet Mask

When you borrow a host bit, you extend the subnet mask, and the network/host boundary moves. Now look at the positional values in the 4th octet. That makes the new dotted-decimal subnet mask:

(spoiler)

255.255.255.128

Remember, to convert from binary to dotted decimal, add up the positional values that have a “1” under them in each octet. Please review Chapter 3.1.1 IPv4 Addressing if you’re having difficulty grasping this concept.

What is the new subnet mask in CIDR notation?

(spoiler)

/25

Now that we have a new subnet mask, we also have a new network boundary. With the original /24, the network could accommodate 254 usable host addresses. With this new /25, let’s calculate how many usable host addresses each network can accommodate.

Calculating how many host addresses within a network

You can calculate how many usable host addresses a network can hold with this formula:

(2H)−2

This is 2 to the power of “H”, minus 2, where “H” is the number of host bits left in the subnet mask.

You subtract 2 because:

  • the network address (the first address in the range) can’t be assigned to a host
  • the broadcast address (the last address in the range) can’t be assigned to a host

With the subnet mask 255.255.255.128, you have 7 host bits left in the 4th octet (because you borrowed 1 of the original 8 host bits). Plug that into the formula:

(27)−2=(128)−2=126

So each /25 network has 126 usable (assignable) host addresses.

Now apply this /25 to the original network and list the resulting ranges.

Starting with the first network (192.168.1.0):

Network Address Assignable Range Broadcast Address
192.168.1.0/25 192.168.1.1 - 192.168.1.126 192.168.1.127

From the table above, the first network’s full range is 192.168.1.0 through 192.168.1.127.

  • Usable/assignable range: 192.168.1.1 - 192.168.1.126 (126 addresses)
  • Not assignable:
    • 192.168.1.0 (network address)
    • 192.168.1.127 (broadcast address)

Since the previous network ended at 192.168.1.127, the next network must begin at 192.168.1.128. That becomes the network address for Network #2.

Network #2

Network Address Assignable Range Broadcast Address
192.168.1.128/25 192.168.1.129 - 192.168.1.254 192.168.1.255

Each network can accommodate 126 usable host addresses.

  • Full range: 192.168.1.128 - 192.168.1.255
  • Usable/assignable range: 192.168.1.129 - 192.168.1.254
  • Broadcast address: 192.168.1.255

At this point, you can’t create another network from 192.168.1.0/24 using /25, because you’ve already used the entire 4th octet range. That’s why a subnet mask of 255.255.255.128 produces only 2 networks, and each of those networks supports 126 usable host addresses.

Practicing subnetting

Let’s try another example. What if you needed 4 networks?

Start with the original subnet mask 255.255.255.0 and use the networks formula. Borrowing 1 host bit isn’t enough:

21=2

Borrowing only 1 host bit gives you 2 networks, which is not enough.

Now try borrowing 2 host bits:

22=4

That works. You need to borrow 2 host bits to create 4 networks.

Next, determine the new subnet mask after borrowing 2 host bits, and then calculate how many usable host addresses fit in each network.

(Image 138)

Image Title - Borrowing two Host bits from the 255.255.255.0 Subnet Mask

The new subnet mask becomes 255.255.255.192 after adding up the positional values with “on” bits in the 4th octet.

What will the new subnet mask (or “prefix length”) be in CIDR notation?

(spoiler)

/26

More subnetting examples

Now calculate how many usable host addresses each of these 4 networks can accommodate. Borrowing 2 host bits from the original 8 in the 4th octet leaves 6 host bits.

Plug that into the host formula:

(26)−2=(64)−2=62

So each of the 4 networks can hold 62 usable (assignable) host addresses. There are 64 total addresses per /26, but 2 are reserved (network and broadcast).

Here are the 4 networks created with this subnet mask:

Network Network Address Assignable Range Broadcast Address
1 192.168.1.0/26 192.168.1.1 - 192.168.1.62 192.168.1.63
2 192.168.1.64/26 192.168.1.65 - 192.168.1.126 192.168.1.127
3 192.168.1.128/26 192.168.1.129 - 192.168.1.190 192.168.1.191
4 192.168.1.192/26 192.168.1.193 - 192.168.1.254 192.168.1.255

Those are the 4 networks in the table above.

  • The full range runs from the network address through the broadcast address.
  • The assignable range is the set of addresses between the network address and the broadcast address.

Let’s do one more example. What if you needed 5 networks?

Borrowing 1 host bit gives 2 networks, and borrowing 2 host bits gives 4 networks - still not enough. Try borrowing 3 host bits:

23=8

Borrowing 3 host bits gives you 8 networks. Even though you only need 5, that’s fine as long as you don’t end up short.

(Image 139)

Image Title - Borrowing three Host bits from the 255.255.255.0 Subnet Mask

The new subnet mask becomes 255.255.255.224, which is /27.

Now calculate usable host addresses per /27. Borrowing 3 host bits leaves 5 host bits:

(25)−2=(32)−2=30

So each /27 network supports 30 usable host addresses.

Here are all the networks:

Network Network Address Assignable Range Broadcast Address
1 192.168.1.0/27 192.168.1.1 - 192.168.1.30 192.168.1.31
2 192.168.1.32/27 192.168.1.33 - 192.168.1.62 192.168.1.63
3 192.168.1.64/27 192.168.1.65 - 192.168.1.94 192.168.1.95
4 192.168.1.96/27 192.168.1.97 - 192.168.1.126 192.168.1.127
5 192.168.1.128/27 192.168.1.129 - 192.168.1.158 192.168.1.159
6 192.168.1.160/27 192.168.1.161 - 192.168.1.190 192.168.1.191
7 192.168.1.192/27 192.168.1.193 - 192.168.1.222 192.168.1.223
8 192.168.1.224/27 192.168.1.225 - 192.168.1.254 192.168.1.255

Subnetting Basics

  • Divides a larger IP network into smaller subnets
  • Achieved by borrowing host bits and extending the subnet mask (increasing prefix length)
  • New network/host boundary defined by the last “1” in the subnet mask

Calculating Number of Networks

  • Formula: 2n (n = number of host bits borrowed)
  • Each borrowed host bit doubles the number of available networks
  • Example: Borrow 1 bit from /24 → /25, yields 2 networks

Subnet Mask Conversion

  • CIDR notation (e.g., /24) corresponds to dotted-decimal (e.g., 255.255.255.0)
  • Extending subnet mask (more "1"s) reduces host bits, increases network bits

Calculating Usable Host Addresses

  • Formula: (2H)−2 (H = number of host bits left)
    • Subtract 2 for network and broadcast addresses
  • Example: /25 (7 host bits) → 126 usable addresses per subnet

Subnetting Examples

  • /25: 2 networks, 126 usable hosts each
  • /26: 4 networks, 62 usable hosts each
  • /27: 8 networks, 30 usable hosts each

Variable Length Subnet Masks (VLSM)

  • Allows different subnet sizes within the same address block
  • Choose subnet mask per network based on required host count
    • Use (2H)−2 to determine minimum host bits needed
  • Example subnet masks for various host requirements:
    • 12 hosts: 255.255.255.240 (/28)
    • 2 hosts: 255.255.255.252 (/30)
    • 40 hosts: 255.255.255.192 (/26)
    • 100 hosts: 255.255.255.128 (/25)
  • More subnetting = more networks, fewer hosts per network

Subnetting with Prefix Lengths Smaller Than /24

  • Subnet masks like /23 (255.255.254.0) or /22 (255.255.252.0) use host bits in the 3rd octet
  • /23: 9 host bits → 510 usable addresses
  • /22: 10 host bits → 1022 usable addresses

Key Formulas

  • Number of networks: 2n (n = host bits borrowed)
  • Usable hosts per subnet: (2H)−2 (H = host bits remaining)

Sign up for free to take 10 quiz questions on this topic

Previous
Next  | 3.3 Routers and IPv4 routing fundamentals
All rights reserved ©2016 - 2026 Achievable, Inc.

Calculating networks and hosts

In this chapter, you’ll learn how to calculate the size of IPv4 networks and how many IP addresses they can hold. This technique is called subnetting.

Subnetting lets you create multiple smaller IP networks from one larger network by extending the subnet mask (in other words, increasing the prefix length). Practically, that means you borrow host bits and turn them into network bits by changing bits in the subnet mask from 0 to 1. After you do that, the point where the 1s stop (and the 0s begin) becomes the new network/host boundary.

Please review Chapter 3.1.2 IPv4 Network Addresses vs. Host Addresses if you’re having trouble following the paragraph above.

Calculating the amount of networks

Let’s walk through an example.

Say you have one IP network, 192.168.1.0/24, and you need to split it into two separate IP networks. You can do that by changing (extending) the original subnet mask.

The subnet mask /24 is written in CIDR notation.

What would be the dotted-decimal representation of this subnet mask?

(spoiler)

255.255.255.0

To divide a network into multiple networks, you borrow host bits from the original subnet mask and convert them into network bits. The key question is: how many host bits do you need to borrow to create the number of networks you want?

You can calculate that with this formula:

2n

This means 2 to the power of “n”, where “n” is the number of host bits you borrow (and turn into network bits). The result is the number of networks you can create with the new subnet mask.

For example, if you borrow 1 host bit, then n=1:

21=2

So, borrowing 1 host bit from a /24 (making it a /25) gives you 2 networks.

Next, let’s look at the host bits available in the original subnet mask. To see the bits clearly, convert the subnet mask to binary.

(Image 136)

Image Title - Subnet Mask 255.255.255.0 with the Binary bits underneath

Now, here’s what the subnet mask looks like after converting one host bit into a network bit:

(Image 137)

Image Title - Borrowing a Host bit from the 255.255.255.0 Subnet Mask

When you borrow a host bit, you extend the subnet mask, and the network/host boundary moves. Now look at the positional values in the 4th octet. That makes the new dotted-decimal subnet mask:

(spoiler)

255.255.255.128

Remember, to convert from binary to dotted decimal, add up the positional values that have a “1” under them in each octet. Please review Chapter 3.1.1 IPv4 Addressing if you’re having difficulty grasping this concept.

What is the new subnet mask in CIDR notation?

(spoiler)

/25

Now that we have a new subnet mask, we also have a new network boundary. With the original /24, the network could accommodate 254 usable host addresses. With this new /25, let’s calculate how many usable host addresses each network can accommodate.

Calculating how many host addresses within a network

You can calculate how many usable host addresses a network can hold with this formula:

(2H)−2

This is 2 to the power of “H”, minus 2, where “H” is the number of host bits left in the subnet mask.

You subtract 2 because:

  • the network address (the first address in the range) can’t be assigned to a host
  • the broadcast address (the last address in the range) can’t be assigned to a host

With the subnet mask 255.255.255.128, you have 7 host bits left in the 4th octet (because you borrowed 1 of the original 8 host bits). Plug that into the formula:

(27)−2=(128)−2=126

So each /25 network has 126 usable (assignable) host addresses.

Now apply this /25 to the original network and list the resulting ranges.

Starting with the first network (192.168.1.0):

Network Address Assignable Range Broadcast Address
192.168.1.0/25 192.168.1.1 - 192.168.1.126 192.168.1.127

From the table above, the first network’s full range is 192.168.1.0 through 192.168.1.127.

  • Usable/assignable range: 192.168.1.1 - 192.168.1.126 (126 addresses)
  • Not assignable:
    • 192.168.1.0 (network address)
    • 192.168.1.127 (broadcast address)

Since the previous network ended at 192.168.1.127, the next network must begin at 192.168.1.128. That becomes the network address for Network #2.

Network #2

Network Address Assignable Range Broadcast Address
192.168.1.128/25 192.168.1.129 - 192.168.1.254 192.168.1.255

Each network can accommodate 126 usable host addresses.

  • Full range: 192.168.1.128 - 192.168.1.255
  • Usable/assignable range: 192.168.1.129 - 192.168.1.254
  • Broadcast address: 192.168.1.255

At this point, you can’t create another network from 192.168.1.0/24 using /25, because you’ve already used the entire 4th octet range. That’s why a subnet mask of 255.255.255.128 produces only 2 networks, and each of those networks supports 126 usable host addresses.

Practicing subnetting

Let’s try another example. What if you needed 4 networks?

Start with the original subnet mask 255.255.255.0 and use the networks formula. Borrowing 1 host bit isn’t enough:

21=2

Borrowing only 1 host bit gives you 2 networks, which is not enough.

Now try borrowing 2 host bits:

22=4

That works. You need to borrow 2 host bits to create 4 networks.

Next, determine the new subnet mask after borrowing 2 host bits, and then calculate how many usable host addresses fit in each network.

(Image 138)

Image Title - Borrowing two Host bits from the 255.255.255.0 Subnet Mask

The new subnet mask becomes 255.255.255.192 after adding up the positional values with “on” bits in the 4th octet.

What will the new subnet mask (or “prefix length”) be in CIDR notation?

(spoiler)

/26

More subnetting examples

Now calculate how many usable host addresses each of these 4 networks can accommodate. Borrowing 2 host bits from the original 8 in the 4th octet leaves 6 host bits.

Plug that into the host formula:

(26)−2=(64)−2=62

So each of the 4 networks can hold 62 usable (assignable) host addresses. There are 64 total addresses per /26, but 2 are reserved (network and broadcast).

Here are the 4 networks created with this subnet mask:

Network Network Address Assignable Range Broadcast Address
1 192.168.1.0/26 192.168.1.1 - 192.168.1.62 192.168.1.63
2 192.168.1.64/26 192.168.1.65 - 192.168.1.126 192.168.1.127
3 192.168.1.128/26 192.168.1.129 - 192.168.1.190 192.168.1.191
4 192.168.1.192/26 192.168.1.193 - 192.168.1.254 192.168.1.255

Those are the 4 networks in the table above.

  • The full range runs from the network address through the broadcast address.
  • The assignable range is the set of addresses between the network address and the broadcast address.

Let’s do one more example. What if you needed 5 networks?

Borrowing 1 host bit gives 2 networks, and borrowing 2 host bits gives 4 networks - still not enough. Try borrowing 3 host bits:

23=8

Borrowing 3 host bits gives you 8 networks. Even though you only need 5, that’s fine as long as you don’t end up short.

(Image 139)

Image Title - Borrowing three Host bits from the 255.255.255.0 Subnet Mask

The new subnet mask becomes 255.255.255.224, which is /27.

Now calculate usable host addresses per /27. Borrowing 3 host bits leaves 5 host bits:

(25)−2=(32)−2=30

So each /27 network supports 30 usable host addresses.

Here are all the networks:

Network Network Address Assignable Range Broadcast Address
1 192.168.1.0/27 192.168.1.1 - 192.168.1.30 192.168.1.31
2 192.168.1.32/27 192.168.1.33 - 192.168.1.62 192.168.1.63
3 192.168.1.64/27 192.168.1.65 - 192.168.1.94 192.168.1.95
4 192.168.1.96/27 192.168.1.97 - 192.168.1.126 192.168.1.127
5 192.168.1.128/27 192.168.1.129 - 192.168.1.158 192.168.1.159
6 192.168.1.160/27 192.168.1.161 - 192.168.1.190 192.168.1.191
7 192.168.1.192/27 192.168.1.193 - 192.168.1.222 192.168.1.223
8 192.168.1.224/27 192.168.1.225 - 192.168.1.254 192.168.1.255
Key points

Subnetting Basics

  • Divides a larger IP network into smaller subnets
  • Achieved by borrowing host bits and extending the subnet mask (increasing prefix length)
  • New network/host boundary defined by the last “1” in the subnet mask

Calculating Number of Networks

  • Formula: 2n (n = number of host bits borrowed)
  • Each borrowed host bit doubles the number of available networks
  • Example: Borrow 1 bit from /24 → /25, yields 2 networks

Subnet Mask Conversion

  • CIDR notation (e.g., /24) corresponds to dotted-decimal (e.g., 255.255.255.0)
  • Extending subnet mask (more "1"s) reduces host bits, increases network bits

Calculating Usable Host Addresses

  • Formula: (2H)−2 (H = number of host bits left)
    • Subtract 2 for network and broadcast addresses
  • Example: /25 (7 host bits) → 126 usable addresses per subnet

Subnetting Examples

  • /25: 2 networks, 126 usable hosts each
  • /26: 4 networks, 62 usable hosts each
  • /27: 8 networks, 30 usable hosts each

Variable Length Subnet Masks (VLSM)

  • Allows different subnet sizes within the same address block
  • Choose subnet mask per network based on required host count
    • Use (2H)−2 to determine minimum host bits needed
  • Example subnet masks for various host requirements:
    • 12 hosts: 255.255.255.240 (/28)
    • 2 hosts: 255.255.255.252 (/30)
    • 40 hosts: 255.255.255.192 (/26)
    • 100 hosts: 255.255.255.128 (/25)
  • More subnetting = more networks, fewer hosts per network

Subnetting with Prefix Lengths Smaller Than /24

  • Subnet masks like /23 (255.255.254.0) or /22 (255.255.252.0) use host bits in the 3rd octet
  • /23: 9 host bits → 510 usable addresses
  • /22: 10 host bits → 1022 usable addresses

Key Formulas

  • Number of networks: 2n (n = host bits borrowed)
  • Usable hosts per subnet: (2H)−2 (H = host bits remaining)

More from IP connectivity

  • Routers and IPv4 routing fundamentals
  • Static routing
  • Static vs. dynamic routing and OSPF fundamentals
  • Router redundancy in an Ethernet LAN using First Hop Redundancy Protocols (FHRPs)