Network Fundamentals · Topic 6 of 17

IPv4 Addressing and Subnetting

Learn how IPv4 addresses and masks work, how to find the network, broadcast and usable host range of a subnet, and how to configure an interface.

  • 6 min
  • Exam objective 1.6
In a nutshell
  • An IPv4 address has 32 bits in four octets.
  • The mask separates the network part from the host part. A prefix like /26 means 26 network bits.
  • Usable hosts equal 2^h minus 2.

What it is

An IPv4 address is a 32-bit number, written as four decimal numbers separated by dots, such as 192.168.10.37.

Each number is one byte, called an octet, and runs from 0 to 255.

Every address has two parts: a network part that identifies the subnet, and a host part that identifies the device inside it.

A subnet mask tells you where the split falls. The mask 255.255.255.0 means the first 24 bits are the network. The same thing is written in prefix notation as /24.

Subnetting means dividing one larger network into smaller ones. You do this by borrowing bits from the host part and using them for the network part. Smaller subnets waste fewer addresses and keep broadcast traffic contained.

How it works

Given an address and a prefix, you can find the subnet boundaries with a few steps.

The key numbers for any subnet

Four values describe every subnet:

  • Network address: the first address, with all host bits set to 0. It identifies the subnet and cannot be given to a device.
  • Broadcast address: the last address, with all host bits set to 1. It reaches every host in the subnet and cannot be given to a device.
  • Usable host range: everything between the two.
  • Number of usable hosts: 2^h minus 2, where h is the number of host bits.
Network192.168.10.0first host is .1Usable hosts.1 to .62next addressBroadcast192.168.10.63

A worked example

Take 192.168.10.37/26.

A /26 mask has 26 network bits, so the mask is 255.255.255.192. There are 6 host bits, so each subnet has 2^6 = 64 addresses.

The block size is 64, and the subnets start at 0, 64, 128 and 192 in the last octet.

The address ends in .37, which sits in the block starting at 0. So:

  • Network address: 192.168.10.0
  • Broadcast address: 192.168.10.63
  • Usable range: 192.168.10.1 to 192.168.10.62
  • Usable hosts: 64 minus 2 = 62

The block size is a quick shortcut. It equals 256 minus the interesting octet of the mask. Here, 256 minus 192 gives 64.

Exam tip

Block size equals 256 minus the mask octet. List the block starts, find the one at or below your address, and the broadcast is one less than the next start.

This table shows common prefixes in the last octet:

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

Choosing a prefix

Work out how many hosts you need, then pick the smallest subnet that fits. For 50 hosts, a /26 (62 hosts) fits and a /27 (30 hosts) does not.

VLSM (variable-length subnet masking) lets you use different prefix lengths inside one address block, so a point-to-point link can use a /30 while a large LAN uses a /24. When you plan with VLSM, allocate the largest subnets first so they do not overlap the smaller ones.

Two special prefixes are worth knowing. A /32 identifies a single host, and is used for loopback addresses and host routes.

A /31 is allowed on point-to-point links and uses both addresses, with no network or broadcast address wasted. Cisco IOS XE supports this.

Classful ranges

Older networks used classes based on the first octet: Class A from 1 to 126, Class B from 128 to 191, Class C from 192 to 223, with Class D (224 to 239) reserved for multicast.

Today, addressing is classless, so the mask decides the network size. The class ranges still appear in questions and in default masks.

Configuring and verifying

interface GigabitEthernet0/0
 ip address 192.168.10.1 255.255.255.192
 no shutdown

To verify:

show ip interface brief
show running-config interface GigabitEthernet0/0
show ip route connected

show ip interface brief lists each interface, its address and its status. show ip route connected shows the connected networks the router has installed.

A host in the subnet needs the same mask and a default gateway inside the same subnet.

What to remember for the exam

Eight facts cover the core of subnetting.

  • An IPv4 address has 32 bits in four octets.
  • The mask separates the network part from the host part. A prefix like /26 means 26 network bits.
  • Usable hosts equal 2^h minus 2.
  • The first address is the network address. The last address is the broadcast address.
  • Block size equals 256 minus the interesting octet of the mask.
  • Common masks: /24 is 255.255.255.0, /25 is .128, /26 is .192, /27 is .224, /28 is .240, /29 is .248, /30 is .252.
  • VLSM uses different prefixes inside one block.
  • A /30 gives 2 usable hosts, which suits a point-to-point link.
Watch out

Always subtract 2 for the network and broadcast addresses. A /27 has 32 addresses but only 30 usable hosts.

Common mistakes

These five slips are common in subnetting.

Using the network or broadcast address for a host. Those two addresses are reserved in each subnet.

Forgetting to subtract 2. A /27 has 32 addresses but only 30 usable hosts.

Putting the gateway in a different subnet. A host and its default gateway must share the same subnet.

Starting subnets in the wrong place. The subnet boundaries follow the block size. With a block of 64, the subnets begin at 0, 64, 128 and 192, not at 10 or 50.

Overlapping subnets. If two subnets share addresses, routing breaks. Allocate the biggest first and keep a plan.

Check yourself

Work through these three prompts.

  • How many usable hosts does a /27 subnet have, and what is its mask?

    A /27 has 32 addresses, so 30 usable hosts, and its mask is 255.255.255.224.

  • What does block size mean, and how do you find it from a mask?

    Block size is the number of addresses in each subnet, so it sets where subnets start, such as 0, 64, 128 and 192. It equals 256 minus the interesting octet of the mask, so 256 minus 192 gives 64.

  • Why is a /30 a good choice for a point-to-point link, and what does VLSM let you do?

    A /30 gives 2 usable hosts, which suits a point-to-point link. VLSM lets you use different prefix lengths inside one address block, such as a /30 for a link and a /24 for a large LAN.

Topic 6 of 17 in Network Fundamentals

Test yourself on Network Fundamentals

The full Cisco CCNA 200-301 question bank has 1,206 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.