1. Home
  2. Guides
  3. How to subnet an IP address, step by step

How to subnet an IP address, step by step

You can find the network, broadcast address and host range of any IP address in under a minute. You only need two ideas: the prefix tells you how many bits belong to the network, and the block size tells you where each subnet starts.

Computer Networks3 min readFree solver inside

What an IP address is made of

An IPv4 address is 32 bits, written as four numbers from 0 to 255, like 192.168.10.77. Each number is one byte, called an octet.

Those 32 bits are split into two parts. The first part names the network. The rest names the host, the single device on that network.

The /26 at the end, called the CIDR prefix, says how many bits belong to the network. Here it's 26, so 6 bits are left for hosts.

The four things you always find

  • Network address: every host bit set to 0. It names the subnet.
  • Broadcast address: every host bit set to 1. A message sent here reaches everyone in the subnet.
  • Usable host range: everything between those two.
  • Number of usable hosts: 2host bits − 2. The 2 are the network and broadcast addresses.

The subnet cheat sheet

PrefixMaskBlock sizeUsable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242

The fast way: block size

You don't have to write out all 32 bits. Use this shortcut instead.

  1. Find the octet where the mask stops being 255. For /26 that's the fourth octet, with mask 192.
  2. Block size = 256 − that mask number. Here, 256 − 192 = 64.
  3. Subnets start at multiples of the block size: 0, 64, 128, 192.
  4. Find the multiple at or just below your number. 77 falls in the block that starts at 64.
  5. So the network is 192.168.10.64. The next block starts at 128, so the broadcast is 127.

The usable hosts run from .65 to .126, and there are 64 − 2 = 62 of them.

Try it yourself

Type any IPv4 address and its prefix, then press Solve. You'll see the binary AND worked out, plus the block-size method as a second way.

Solved examples

Example 1: a /26 network

Question: Find the network address, broadcast address and usable host range of 192.168.10.77/26.

Plan: how this problem is solved
  1. Write the given values
  2. Write the IP address in binary (8 bits per number)
  3. Build the subnet mask: 26 ones, then 6 zeros
  4. Network address = IP AND mask (a bit stays 1 only if both bits are 1)
  5. Broadcast address: keep the network bits and set every host bit to 1
  6. Count the addresses and usable hosts

There is also another method, shown after the solution: the block-size method (no binary).

Answer
Network address192.168.10.64/26
Subnet mask255.255.255.192
Broadcast address192.168.10.127
Usable host range192.168.10.65 – 192.168.10.126
Usable hosts62
Wildcard mask0.0.0.63
Class / typeClass C, private address
Step-by-step solution
  1. Write the given values
    IP=192.168.10.77
    p=26
  2. Write the IP address in binary (8 bits per number)
    1921681077
    11000000101010000000101001001101
  3. Build the subnet mask: 26 ones, then 6 zeros
    11111111.11111111.11111111.11000000
    = 255.255.255.192
  4. Network address = IP AND mask (a bit stays 1 only if both bits are 1)
      11000000.10101000.00001010.01001101  (IP)
    & 11111111.11111111.11111111.11000000  (mask)
      ───────────────────────────────────
      11000000.10101000.00001010.01000000
    = 192.168.10.64
  5. Broadcast address: keep the network bits and set every host bit to 1
      11000000.10101000.00001010.01111111
    = 192.168.10.127
    The last 6 bits are host bits.
  6. Count the addresses and usable hosts
    Total=232 − 26 = 26
    =64
    Usable=64 − 2 = 62
    We take away 2: the network address and the broadcast address can't be given to a device.
Another way: the block-size method (no binary)

Fast way used in exams: find the "interesting" octet, the one where the mask is not 255 or 0.

  1. Block size = 256 − mask value in octet 4
    =256 − 192
    =64
    Subnets in that octet start at 0, 64, 128, 192 …
  2. Find the block that holds 77
    Start=⌊77 ÷ 64⌋ × 64
    =64
    End=64 + 64 − 1 = 127
    Octet 4 of the network address is 64 and of the broadcast address is 127. Octets after it are 0 (network) and 255 (broadcast). This matches the answer above.
Key idea: The prefix splits the 32 bits of an address into two parts. The left part names the network, the right part names a device on it. Borrowing more bits for the network gives you more subnets, each with fewer hosts.

Example 2: a /20 network (the third octet)

Question: How many usable hosts are there in 10.4.17.200/20, and what is its network address?

Plan: how this problem is solved
  1. Write the given values
  2. Write the IP address in binary (8 bits per number)
  3. Build the subnet mask: 20 ones, then 12 zeros
  4. Network address = IP AND mask (a bit stays 1 only if both bits are 1)
  5. Broadcast address: keep the network bits and set every host bit to 1
  6. Count the addresses and usable hosts

There is also another method, shown after the solution: the block-size method (no binary).

Answer
Network address10.4.16.0/20
Subnet mask255.255.240.0
Broadcast address10.4.31.255
Usable host range10.4.16.1 – 10.4.31.254
Usable hosts4,094
Wildcard mask0.0.15.255
Class / typeClass A, private address
Step-by-step solution
  1. Write the given values
    IP=10.4.17.200
    p=20
  2. Write the IP address in binary (8 bits per number)
    10417200
    00001010000001000001000111001000
  3. Build the subnet mask: 20 ones, then 12 zeros
    11111111.11111111.11110000.00000000
    = 255.255.240.0
  4. Network address = IP AND mask (a bit stays 1 only if both bits are 1)
      00001010.00000100.00010001.11001000  (IP)
    & 11111111.11111111.11110000.00000000  (mask)
      ───────────────────────────────────
      00001010.00000100.00010000.00000000
    = 10.4.16.0
  5. Broadcast address: keep the network bits and set every host bit to 1
      00001010.00000100.00011111.11111111
    = 10.4.31.255
    The last 12 bits are host bits.
  6. Count the addresses and usable hosts
    Total=232 − 20 = 212
    =4096
    Usable=4096 − 2 = 4094
    We take away 2: the network address and the broadcast address can't be given to a device.
Another way: the block-size method (no binary)

Fast way used in exams: find the "interesting" octet, the one where the mask is not 255 or 0.

  1. Block size = 256 − mask value in octet 3
    =256 − 240
    =16
    Subnets in that octet start at 0, 16, 32, 48 …
  2. Find the block that holds 17
    Start=⌊17 ÷ 16⌋ × 16
    =16
    End=16 + 16 − 1 = 31
    Octet 3 of the network address is 16 and of the broadcast address is 31. Octets after it are 0 (network) and 255 (broadcast). This matches the answer above.
Key idea: The prefix splits the 32 bits of an address into two parts. The left part names the network, the right part names a device on it. Borrowing more bits for the network gives you more subnets, each with fewer hosts.

In the /20 example the mask stops in the third octet (240), so the block size, 16, applies there. 17 falls in the block 16 to 31. That's why the network is 10.4.16.0 and the broadcast is 10.4.31.255.

Common mistakes

  • Forgetting the − 2. A /26 has 64 addresses but only 62 usable hosts.
  • Using the wrong octet. The block size applies to the octet where the mask isn't 255 or 0.
  • Leaving later octets alone. For the network address, every octet after the interesting one becomes 0. For broadcast, they become 255.

Private address ranges

Three ranges are kept for home and office networks and never appear on the open internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Your home Wi-Fi almost surely uses one of them.

Practice questions

Work them out with the block-size method, then load each into the calculator to check.

  1. A host has address 172.16.45.14 with mask 255.255.255.240 (/28). Find its subnet and broadcast address.

    Show the answer

    network 172.16.45.0, broadcast 172.16.45.15

  2. Find the network and broadcast address of 192.168.1.130/25, and the number of usable hosts.

    Show the answer

    network 192.168.1.128, broadcast 192.168.1.255, 126 hosts

Words used in this guide

Plain meanings, so you don't have to look them up anywhere else.

Bit
A single binary digit, 0 or 1. 8 bits make one byte.
IP address (IPv4)
A 32-bit number that names a device on a network, written as four numbers from 0 to 255, like 192.168.1.10.
Subnet mask and prefix (/26)
Tells which part of the address is the network. /26 means the first 26 bits are network bits, which is mask 255.255.255.192.
Network address
The first address of a subnet, with all host bits set to 0. It names the subnet itself and isn't given to any device.
Broadcast address
The last address of a subnet, with all host bits set to 1. A message sent here reaches every device in that subnet.
Host and usable hosts
A host is any device with an address: a laptop, phone or printer. Usable hosts are the addresses left after removing the network and broadcast addresses.
Wildcard mask
The subnet mask with every bit flipped. Routers use it in access lists; for /26 it's 0.0.0.63.
Private IP address
Ranges kept for home and office networks: 10.x.x.x, 172.16–31.x.x and 192.168.x.x. They aren't reachable directly from the internet.

Frequently asked questions

How do you find the network address of an IP?
Set every host bit to 0. The quick way: find the block size (256 minus the interesting mask octet) and round the address down to the nearest multiple of it.
How many hosts are in a /26 subnet?
A /26 leaves 6 host bits, so 2⁶ = 64 addresses. Take away the network and broadcast addresses and you get 62 usable hosts.
What is the subnet mask for /24?
255.255.255.0. The first 24 bits are 1s, which makes the first three octets 255.
What is a broadcast address?
The last address in a subnet, with all host bits set to 1. A packet sent to it reaches every device in that subnet.