These topics are essential for Cisco networking, CCNA, AWS VPC networking, Linux administration, cybersecurity, and enterprise network design .
Our goal is not just to memorize IP addresses. By the end, you should be able to look at an IP address, calculate its network, identify its host range, determine the broadcast address, and understand how to divide a network into subnets.
Table of contents [Show]
- Your learning roadmap
- 1. What is an IP address?
- 2. The two main IP versions
- 3. What does an IP address look like?
- 192.168.1.10
- 4. What happens when you type a website address?
- 1. The main characteristics of IPv4
- 2. IPv4 is a 32-bit address
- 3. Understanding binary place values
- 1. Example: 192.168.1.10/24
- 192
- 168
- 1
- 10
- 2. Why must devices understand the network portion?
- 3. How many hosts can a subnet support?
- 1. Think of an IP network as a street
- 2. What are IPv4 address classes?
- 3. Address class ranges
- 1. Class A
- 2. Class B
- 3. Compare Class A and Class B
- 1. Class C
- 2. Class D: multicast
- 3. Class E: reserved/experimental
- 4. Class identification practice
- 1. Network address
- 2. Directed broadcast address
- 3. Other special-use ranges
- Example: a computer looking for a DHCP server
- 1. What does loopback do?
- 2. Try it on Kali Linux
- 3. Common loopback mistakes
- 1. The three private IPv4 ranges
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
- 2. Important distinction: not every 172 address is private
- 3. How private addresses reach the internet
- 1. Private address ranges and their historical classes
- 2. IPv4 link-local addresses
- 1. Common subnet masks
- 2. How a subnet mask works
- 3. Subnet masks do not have to match historical address classes
- 1. Calculate a subnet using the block-size method
- Worked example: 192.168.10.77/26
- 2. Calculate another example
- 3. What is a discontiguous subnet mask?
- Part 1: Understanding CIDR notation
- Part 2: Prefix lengths in practice
- Explore an IPv4 prefix
- /24
- How to interpret the results
- 1. The five-step subnetting method
- Worked solution
- 2. Subnet a network into multiple smaller networks
- 3. Variable Length Subnet Masking (VLSM)
- 4. Practical Linux demonstration
- 10-question networking quiz
- What you should master before moving on
Your learning roadmap
Foundation: IP addressing
26–31: IP address basics, IPv4 structure, network and host portions, the street analogy, and address classes A–E.
Special addresses and private networks
32–36: Broadcast addresses, loopback, RFC1918 private ranges, and IPv4 link-local addressing.
Subnet masks and CIDR
37–40: Binary masks, subnet calculations, discontiguous masks, CIDR notation, and practical exercises.
Lesson 26. IP Addressing Overview and Demonstration
1. What is an IP address?
An IP address is a logical address used to identify a network interface and help deliver data across IP networks.
Think about sending a parcel from Lagos to a business in Abuja. The delivery service needs enough address information to determine where the parcel should go.
A computer network works in a similar way. When your laptop sends a request to a web server, IP addressing helps identify the source and destination of the traffic.
For example:
Your laptop
192.168.1.10
Router
192.168.1.1
Web server
203.0.113.20*
*The server address is an example from a documentation-only IP range, not a real public server.
When your laptop communicates with a server:
The source IP address identifies the sending interface.
The destination IP address identifies the intended destination.
Routers examine the destination IP and their routing tables to decide where to forward the packet.
The local network uses other information, such as MAC addresses, to deliver frames over the local link.
An IP address alone does not necessarily identify a person or a physical device permanently. One device can have multiple IP addresses, and addresses can change.
2. The two main IP versions
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address size | 32 bits | 128 bits |
| Format | Four decimal octets | Hexadecimal groups separated by colons |
| Example | 192.168.1.10 | 2001:db8::10 |
| Address capacity | About 4.29 billion possible bit patterns | \(2^{128}\) possible bit patterns |
| Typical use | Common in LANs, WANs and the internet | Modern networks, mobile networks and internet infrastructure |
We are concentrating on IPv4 , because that is what your lessons 26–40 cover.
3. What does an IP address look like?
Consider this IPv4 address:
192.168.1.10
192
Octet 1
168
Octet 2
1
Octet 3
10
Octet 4
Four octets × 8 bits each = 32 bits.
Each number is called an octet because it represents eight bits.
An IPv4 address has:
4 octets.
8 bits per octet.
32 bits in total.
A decimal value from 0 to 255 in each octet.
Why 0–255? Because eight binary bits can represent \(2^8 = 256\) different values, starting at 0 and ending at 255.
4. What happens when you type a website address?
Suppose you enter a website name in your browser.
DNS resolves the website name to an IP address.
Your computer determines whether the destination is on its local subnet.
If the destination is local, your computer sends the packet over the local network.
If the destination is remote, your computer normally sends the packet to its default gateway.
Routers forward the packet toward its destination.
The important point: IP addressing and subnet masks help a computer determine whether a destination is local or remote.
That leads us to the next lesson.
Lesson 27. IP Characteristics and IPv4 Address Format
1. The main characteristics of IPv4
Logical addressing: An IP address is assigned to a network interface, manually or automatically.
Hierarchical addressing: An address can be interpreted as a network portion and a host portion, according to a subnet mask or prefix length.
Routability: Routers use destination IP addresses and routing tables to forward packets between networks.
Connectionless delivery: IP does not establish a dedicated end-to-end connection before sending packets. Other protocols, such as TCP, may provide connection-oriented communication.
Best-effort delivery: IP itself does not guarantee that packets arrive, arrive only once, or arrive in order.
Address configuration: Addresses can be configured manually (static addressing) or assigned dynamically, commonly through DHCP.
2. IPv4 is a 32-bit address
Let's convert 192.168.1.10 into binary.
Each decimal octet is converted separately.
| Decimal | Binary |
|---|---|
| 192 | 11000000 |
| 168 | 10101000 |
| 1 | 00000001 |
| 10 | 00001010 |
The complete address is:
11000000.10101000.00000001.00001010
Remove the dots, and you have 32 bits.
3. Understanding binary place values
Each bit has a place value:
128
64
32
16
8
4
2
1
Read from left to right: 128, 64, 32, 16, 8, 4, 2, 1.
To convert binary 11000000 to decimal:
First bit is 1, so add 128.
Second bit is 1, so add 64.
The remaining bits are zero.
Therefore, \(128+64=192\) .
To convert decimal 10 to binary:
\(8+2=10\) , so the bits for 8 and 2 are set.
00001010
Practical demonstration
On Linux, including Kali Linux, run:
ip -4 addr show
ip routeThe first command displays IPv4 addresses assigned to your interfaces. The second shows routes, including the default gateway if one is configured.
You may see addresses like 127.0.0.1, a private LAN address, and possibly other addresses depending on your setup.
Don't worry if your output differs from the examples. Your addresses depend on your network configuration.
Lesson 28. Network Portion versus Host Portion
This is one of the most important concepts in all of IPv4 networking.
An IPv4 address is interpreted using two pieces of information:
Network portion: Identifies the IP network or subnet.
Host portion: Identifies an address within that subnet.
The subnet mask or CIDR prefix tells the computer where the network portion ends and the host portion begins.
1. Example: 192.168.1.10/24
The /24 means the first 24 bits belong to the network portion, leaving 8 bits for the host portion.
192
Network
168
Network
1
Network
10
Host
24 network bits
8 host bits
The subnet is 192.168.1.0/24.
| Property | Value |
|---|---|
| Network address | 192.168.1.0 |
| First usable host | 192.168.1.1 |
| Last usable host | 192.168.1.254 |
| Broadcast address | 192.168.1.255 |
| Total addresses | 256 |
| Traditionally usable host addresses | 254 |
For a conventional IPv4 subnet, the all-zero host portion identifies the network, and the all-one host portion identifies the subnet's broadcast address.
2. Why must devices understand the network portion?
Imagine these two computers:
Computer A:
192.168.1.10/24Computer B:
192.168.1.20/24
Both belong to 192.168.1.0/24, so they can communicate directly over the local network, assuming the network allows it.
Now consider:
Computer A:
192.168.1.10/24Computer C:
192.168.2.20/24
Computer C belongs to 192.168.2.0/24. Computer A treats it as a remote destination and normally sends the traffic to its default gateway.
Important: Different subnets need routing to communicate. Being connected to the same physical switch does not automatically make two different IP subnets communicate.
3. How many hosts can a subnet support?
For a conventional IPv4 subnet, the standard formula is:
Here, \(h\) is the number of host bits.
For /24:
For /26:
The subtraction of two applies to conventional subnets with separate network and broadcast addresses. Special cases such as /31 point-to-point links and /32 host routes require different treatment.
Lesson 29. IPv4 Street Analogy and Address Classes
1. Think of an IP network as a street
Imagine a city with different streets, each containing several houses.
Street = network; house = host
Street name: the network portion.
House number: the host portion.
City directory: routing information.
Local street delivery: communication within a subnet.
Road connecting different streets: a router.
Suppose you have the address 192.168.1.10/24.
192.168.1represents the network portion in this particular/24subnet.10represents the host portion.192.168.1.0/24is the street or subnet.192.168.1.255is the subnet's broadcast address.
The analogy is useful, but remember that the actual network/host boundary is determined by the prefix length, not by where the dots appear.
2. What are IPv4 address classes?
Historically, IPv4 used a system called classful addressing . Addresses were grouped into Classes A, B, C, D and E based mainly on the first bits of the address.
In the original classful system:
Class A used a default
/8network prefix.Class B used a default
/16network prefix.Class C used a default
/24network prefix.Class D was for multicast.
Class E was reserved for experimental or future use.
Modern networks generally use CIDR (Classless Inter-Domain Routing) , which allows flexible prefix lengths.
Classes are still important for understanding older networking material, exams, and historical terminology.
3. Address class ranges
| Class | First octet | Default prefix historically | Main purpose |
|---|---|---|---|
| A | 1–126, with 0 and 127 special | /8 | Large classful networks |
| B | 128–191 | /16 | Medium-sized classful networks |
| C | 192–223 | /24 | Smaller classful networks |
| D | 224–239 | Not applicable | Multicast |
| E | 240–255 | Not applicable | Reserved/experimental range |
The first-octet ranges above describe the traditional class boundaries, with special-use qualifications for some addresses. Class D and E are not ordinary unicast host classes.
Memory trick:
A: 1–126
B: 128–191
C: 192–223
D: 224–239
E: 240–255
Notice that 127 is excluded from ordinary Class A host use because 127.0.0.0/8 is reserved for loopback.
Lesson 30. Class A and Class B Addresses
1. Class A
Class A addresses historically had the first bit set to 0, giving a first-octet range of 0–127. However, 0.0.0.0/8 and 127.0.0.0/8 have special purposes, so the familiar ordinary Class A range is 1–126 in the first octet.
The historical default subnet mask was:
255.0.0.0
This is /8.
Example:
10.20.30.40
Under the old classful system:
Network portion:
10Host portion:
20.30.40Default network:
10.0.0.0/8
That network contains \(2^{24}\) addresses, or 16,777,216 total addresses. Under conventional subnetting, 16,777,214 would be usable host addresses if the full /8 were used as one subnet.
Today, an address starting with 10 could be configured with many different prefix lengths. The first octet alone does not tell you the actual subnet.
2. Class B
Class B addresses have first octets from 128 to 191.
The historical default subnet mask was:
255.255.0.0
This is /16.
Example:
172.20.30.40
Under the old classful system:
Network portion:
172.20Host portion:
30.40Default network:
172.20.0.0/16
A /16 contains \(2^{16}=65,536\) addresses, traditionally giving 65,534 usable host addresses when used as a conventional subnet.
3. Compare Class A and Class B
| Characteristic | Class A | Class B |
|---|---|---|
| First-octet range | 1–126, ordinary historical range | 128–191 |
| Default mask | 255.0.0.0 | 255.255.0.0 |
| Default prefix | /8 | /16 |
| Host bits | 24 | 16 |
| Total addresses per default network | 16,777,216 | 65,536 |
| Traditional usable hosts | 16,777,214 | 65,534 |
These large classful networks often wasted address space. Modern subnetting allows administrators to allocate address ranges more efficiently.
Lesson 31. Class C, D, E and Reviewing A and B
1. Class C
Class C addresses have first octets from 192 to 223.
Historical default mask:
255.255.255.0 or /24
Example:
192.168.1.25
Under classful addressing:
Network portion:
192.168.1Host portion:
25Network:
192.168.1.0/24
A /24 contains 256 total addresses and traditionally 254 usable host addresses.
2. Class D: multicast
Class D addresses range from 224.0.0.0 through 239.255.255.255.
Multicast allows one sender to transmit traffic intended for a group of receivers that have joined or are listening to that multicast group.
For example, multicast may be used for certain streaming, discovery, routing and enterprise network applications.
Multicast addresses are not ordinary host addresses that you assign to a workstation as its unicast identity.
3. Class E: reserved/experimental
Class E covers 240.0.0.0 through 255.255.255.255 under the historical class system.
This range was reserved for experimental or future use. It is not an ordinary pool for general-purpose unicast host addressing. The all-ones address, 255.255.255.255, has the special meaning of limited broadcast.
4. Class identification practice
Try identifying the historical address class
Enter any IPv4 address and use its first octet to identify the class.
Check address
Lesson 32. Special IPv4 Addresses and Directed Broadcast
Some IPv4 addresses have special meanings and should not be treated like ordinary host addresses.
1. Network address
The network address has all host bits set to zero.
Example:
192.168.1.0/24
The network address is 192.168.1.0.
It identifies the subnet itself rather than an ordinary host interface.
2. Directed broadcast address
A directed broadcast targets all hosts on a specific IPv4 subnet. Routers historically could forward directed broadcasts to that subnet, but forwarding is commonly disabled for security reasons.
For the network 192.168.1.0/24, the directed broadcast address is:
192.168.1.255
A packet addressed to this destination is intended for all hosts on that specific subnet if the network permits directed broadcast forwarding.
Another example:
Network: 172.16.8.0/21
A /21 mask is 255.255.248.0. Its block size in the third octet is 8, so this subnet spans third-octet values 8 through 15.
Network:
172.16.8.0Broadcast:
172.16.15.255Conventional usable host range:
172.16.8.1–172.16.15.254
3. Other special-use ranges
| Address/range | Purpose |
|---|---|
0.0.0.0 | Unspecified IPv4 address in appropriate contexts |
0.0.0.0/8 | Historically special zero network range |
127.0.0.0/8 | Loopback |
169.254.0.0/16 | IPv4 link-local |
224.0.0.0/4 | IPv4 multicast |
255.255.255.255 | Limited broadcast |
100.64.0.0/10 | Shared address space, commonly used by service providers for carrier-grade NAT |
Remember: the purpose of an address depends on the exact address and its prefix, not just on whether it looks familiar.
Lesson 33. Local Broadcast Address
The local broadcast address , also called the limited broadcast address, is:
255.255.255.255
It is used to send a broadcast packet to hosts on the local IPv4 network segment. Routers do not forward this limited broadcast to other networks.
Example: a computer looking for a DHCP server
Imagine you connect a new laptop to a network but it has not yet received an IPv4 address.
The laptop may send a DHCP discovery message using a source address of 0.0.0.0 and a destination address of 255.255.255.255.
Why?
The laptop does not yet know its assigned IPv4 address, and it may not know the address of a DHCP server. Broadcasting allows it to discover available DHCP service on the local network.
New laptop
0.0.0.0
Local LAN
Broadcast
The broadcast can reach listening devices on the local segment, subject to network configuration.
Local broadcast versus directed broadcast
| Feature | Limited/local broadcast | Directed broadcast |
|---|---|---|
| Example | 255.255.255.255 | 192.168.1.255 for 192.168.1.0/24 |
| Intended scope | Local network segment | A particular IP subnet |
| Router forwarding | Not forwarded by routers | Normally disabled for security |
| Typical context | DHCP discovery | Special network-management scenarios |
Do not confuse the two addresses. A directed broadcast depends on the destination subnet's mask.
Lesson 34. Local Loopback Address
The loopback range is:
127.0.0.0/8
The most familiar loopback address is:
127.0.0.1
It is commonly called localhost.
1. What does loopback do?
Loopback lets a computer communicate with its own networking stack without sending the traffic out through its physical network interface to another device.
For example, if you are developing a web application on Kali Linux and run a development server on port 3000, you might visit:
http://127.0.0.1:3000
This connects to a service listening on your own machine at that address and port.
It does not connect you to another computer at 127.0.0.1.
2. Try it on Kali Linux
Run:
ping -c 4 127.0.0.1You should normally receive replies from your own system's loopback interface.
You can also check the local interface:
ip addr show loThe lo interface is the loopback interface.
3. Common loopback mistakes
127.0.0.1always refers to the local machine from the perspective of the system using it.It is not the address of your router.
It is not your public internet IP address.
Another computer cannot use your
127.0.0.1address to reach your machine.A successful loopback test does not prove that your Wi-Fi, Ethernet, gateway, or internet connection works.
For troubleshooting, loopback tests the local TCP/IP stack, not the whole network path.
Lesson 35. RFC1918 — Private IPv4 Addresses
RFC1918 defines three IPv4 ranges reserved for private internets. These addresses are intended for internal networks and are not globally routed across the public internet.
The three ranges are extremely important for home networks, offices, hotels, hospitals, schools and cloud environments.
1. The three private IPv4 ranges
Private range 1
10.0.0.0/8
10.0.0.0 – 10.255.255.255
Often used for large organizations, enterprise networks and cloud VPC address plans.
Private range 2
172.16.0.0/12
172.16.0.0 – 172.31.255.255
Often used for departmental networks, internal services and medium-to-large deployments.
Private range 3
192.168.0.0/16
192.168.0.0 – 192.168.255.255
Very common in home routers, small offices, Wi-Fi networks and local equipment.
2. Important distinction: not every 172 address is private
The private range is specifically:
172.16.0.0 through 172.31.255.255
Therefore:
172.16.1.10— private.172.20.5.10— private.172.31.255.254— private.172.15.1.10— not RFC1918 private.172.32.1.10— not RFC1918 private.
This is a common exam question and a common configuration mistake.
3. How private addresses reach the internet
Suppose your laptop uses 192.168.1.10 and your router has a public-facing address.
When you browse the internet, your router may perform Network Address Translation (NAT) , commonly using Port Address Translation (PAT), to allow multiple internal devices to share a public IPv4 address.
Laptop
192.168.1.10
Phone
192.168.1.11
Router / NAT
Translates eligible traffic
Public internet
NAT is not the same thing as a private address. Private addressing is an allocation convention; NAT is a translation mechanism. You can have private networks without internet access, and you can use NAT for purposes other than ordinary internet access.
Lesson 36. RFC1918 Class A, B, C and IPv4 Link-Local Addresses
This lesson connects private address ranges with historical address classes.
1. Private address ranges and their historical classes
| Private range | Historical class association | CIDR prefix |
|---|---|---|
10.0.0.0–10.255.255.255 | Class A | /8 |
172.16.0.0–172.31.255.255 | Class B | /12 |
192.168.0.0–192.168.255.255 | Class C | /16 |
Notice the distinction between a historical class and a private allocation prefix.
The RFC1918 ranges are /8, /12 and /16, respectively. They do not mean every network must use that entire range as one subnet.
For example, an organization may allocate:
10.10.20.0/24
That is a subnet taken from the private 10.0.0.0/8 range.
2. IPv4 link-local addresses
The IPv4 link-local range is:
169.254.0.0/16
It is separate from RFC1918 private addressing.
A device may automatically configure a link-local address when it cannot obtain an IPv4 address through DHCP, depending on its operating system and configuration.
For example:
169.254.23.15
This can allow certain communications between devices on the same link. However, it does not ordinarily provide routable connectivity to other subnets or the public internet.
Troubleshooting example
You connect a laptop to a router, but it receives 169.254.23.15 instead of the expected 192.168.1.x address.
Possible causes include:
The DHCP server is unavailable.
The router's DHCP service is disabled.
The Wi-Fi or Ethernet connection has a problem.
A VLAN, switch port or relay configuration is incorrect.
The DHCP pool is exhausted.
Do not immediately conclude that the laptop's network card is faulty. Investigate the DHCP process and the physical or wireless link.
Verify the address on Linux
ip -4 addr show
ip routeIf you see a 169.254.x.x address, check whether the interface has the expected DHCP address and whether a default route is present.
Lesson 37. Subnet Masks
Now we move into a concept that separates basic IP familiarity from practical network engineering.
A subnet mask identifies which bits of an IPv4 address belong to the network portion and which bits belong to the host portion.
1. Common subnet masks
| CIDR prefix | Subnet mask | Host bits | Conventional usable hosts |
|---|---|---|---|
/8 | 255.0.0.0 | 24 | 16,777,214 |
/16 | 255.255.0.0 | 16 | 65,534 |
/24 | 255.255.255.0 | 8 | 254 |
/25 | 255.255.255.128 | 7 | 126 |
/26 | 255.255.255.192 | 6 | 62 |
/27 | 255.255.255.224 | 5 | 30 |
/28 | 255.255.255.240 | 4 | 14 |
/29 | 255.255.255.248 | 3 | 6 |
/30 | 255.255.255.252 | 2 | 2 |
These host counts assume conventional IPv4 subnets with a network and broadcast address. /31 point-to-point links and /32 host routes are exceptions.
2. How a subnet mask works
Consider:
IP address:
192.168.1.10Subnet mask:
255.255.255.0
In binary, the mask is:
11111111.11111111.11111111.00000000
Every 1 bit indicates a network bit; every 0 bit indicates a host bit.
The mask has 24 ones and 8 zeros. That is why it is called /24.
The network address is found by performing a bitwise AND between the IP address and subnet mask.
For the last octet:
00001010 (10) AND 00000000 (0) = 00000000 (0)
So the network address is 192.168.1.0.
3. Subnet masks do not have to match historical address classes
You can assign a /26 mask to an address that historically belonged to Class C.
For example:
192.168.1.10/26
This is not the entire 192.168.1.0/24 subnet. It belongs to the smaller subnet 192.168.1.0/26.
Its details are:
Network:
192.168.1.0First host:
192.168.1.1Last host:
192.168.1.62Broadcast:
192.168.1.63
The next /26 subnet begins at 192.168.1.64.
This is the basic principle of subnetting: dividing a larger address range into smaller networks.
Lesson 38. Subnet Mask Demonstrations and Discontiguous Network Masks
1. Calculate a subnet using the block-size method
Suppose you are given:
IP address:
192.168.10.77Subnet mask:
255.255.255.192
First, identify the prefix.
255.255.255.192 = /26
The mask's last octet is 192. Calculate the block size:
Therefore, subnet boundaries in the last octet occur at:
0, 64, 128, 192
Which subnet contains 77? It falls between 64 and 127.
Worked example: 192.168.10.77/26
Network address
192.168.10.64
Broadcast address
192.168.10.127
First usable host
192.168.10.65
Last usable host
192.168.10.126
64 total addresses, 62 conventional usable host addresses.
2. Calculate another example
IP address: 172.16.35.200/20
The /20 mask is:
255.255.240.0
The interesting octet is the third octet because 240 is the mask value there.
Block size:
The third-octet boundaries are 0, 16, 32, 48, 64 and so on.
Since 35 falls between 32 and 47, the result is:
Network:
172.16.32.0/20First host:
172.16.32.1Last host:
172.16.47.254Broadcast:
172.16.47.255Total addresses: 4,096
Conventional usable hosts: 4,094
3. What is a discontiguous subnet mask?
A discontiguous mask has network bits interrupted by host bits. In binary, its 1 bits are not one continuous block followed by 0 bits.
For example, this mask is discontiguous:
255.0.255.0
In binary:
11111111.00000000.11111111.00000000
It contains network bits, then host bits, then network bits again, followed by host bits.
That is not a valid conventional subnet mask for modern IPv4 CIDR networks.
A conventional mask must have contiguous network bits from the left, followed only by host bits. Valid examples include:
255.255.255.0—/24255.255.255.128—/25255.255.240.0—/20
An important distinction: discontiguous network masks are not the same as discontiguous networks. Older classful routing protocols sometimes used the term discontiguous network to describe portions of the same major network separated by another network. That is a different routing concept.
For ordinary IPv4 subnetting and CIDR, use contiguous masks.
Lesson 39. CIDR Notation — Parts 1 and 2
CIDR stands for Classless Inter-Domain Routing .
It was introduced to reduce the limitations of classful addressing and make IP allocation and routing more efficient.
Part 1: Understanding CIDR notation
CIDR represents a network using an IP address followed by a slash and a prefix length.
Examples:
192.168.1.0/2410.0.0.0/8172.16.0.0/16192.168.1.64/26
The number after the slash specifies how many leading bits belong to the network portion.
For example:
192.168.1.0/24
The /24 means 24 network bits and 8 host bits.
The conventional host-count formula is:
Here, \(p\) is the prefix length, subject to the /31 and /32 exceptions discussed earlier.
Part 2: Prefix lengths in practice
Explore an IPv4 prefix
Prefix length
/24
Subnet mask
255.255.255.0
Network bits
24
Host bits
8
Total addresses
256
Conventional usable hosts
254
This calculator shows subnet capacity for a prefix, not a complete network-range calculation for an arbitrary entered IP address.
How to interpret the results
A /24 provides 256 total addresses and 254 conventional usable hosts.
A /26 provides 64 total addresses and 62 conventional usable hosts.
A /28 provides 16 total addresses and 14 conventional usable hosts.
A /30 provides four total addresses and two conventional usable hosts. It is commonly encountered in older point-to-point IPv4 links.
A /32 identifies one exact IPv4 address and is commonly used for host routes.
Why CIDR is better than classful addressing
Imagine a company needs 50 host addresses.
Under traditional classful allocation, a Class C network would be the familiar /24, with 254 conventional usable addresses. That is more than the company needs.
CIDR allows a /26, with 62 conventional usable host addresses, which may be a better fit.
CIDR also supports route aggregation, allowing routers to represent multiple contiguous networks with a single summary route when the addressing and routing conditions permit.
Lesson 40. CIDR Notation — Part 3: Practical Subnetting
This is where we bring everything together. In real networking work, you will often be given an IP address and prefix and asked to calculate the network address, broadcast address, host range and number of hosts.
1. The five-step subnetting method
When you see an address such as 192.168.50.130/26, follow these steps.
Identify the prefix.
/26means 26 network bits and 6 host bits.Find the subnet mask.
/26equals255.255.255.192.Calculate the block size. In the fourth octet, \(256-192=64\) .
Find the subnet boundary. The boundaries are 0, 64, 128 and 192. Address 130 falls in the 128–191 block.
Calculate the network, broadcast and host range. The network is
.128, broadcast is.191, and conventional usable hosts run from.129to.190.
Worked solution
Given: 192.168.50.130/26
Network address
192.168.50.128
Subnet mask
255.255.255.192
First usable host
192.168.50.129
Last usable host
192.168.50.190
Broadcast address
192.168.50.191
Total / usable addresses
64 / 62
2. Subnet a network into multiple smaller networks
Suppose a hotel uses the network 192.168.10.0/24 and wants four equal-sized subnets for staff, guests, CCTV and servers.
We can divide the /24 into four /26 subnets.
Why /26? Each additional network bit doubles the number of equal-sized subnets. Moving from /24 to /26 adds two network bits, giving \(2^2=4\) subnets.
| Department | Subnet | Usable host range | Broadcast |
|---|---|---|---|
| Staff | 192.168.10.0/26 | .1–.62 | .63 |
| Guests | 192.168.10.64/26 | .65–.126 | .127 |
| CCTV | 192.168.10.128/26 | .129–.190 | .191 |
| Servers | 192.168.10.192/26 | .193–.254 | .255 |
In the table, abbreviated host ranges refer to addresses within 192.168.10.x.
Visualise the four subnets
0–63
Staff
64–127
Guests
128–191
CCTV
192–255
Servers
Each subnet contains 64 addresses, including its network and broadcast addresses.
This is an example of how a network engineer can organise traffic and improve network management. For stronger isolation, the network would also use VLANs, routing and appropriate firewall or access-control rules; subnetting alone does not enforce security.
3. Variable Length Subnet Masking (VLSM)
Not every department needs the same number of IP addresses.
Imagine a company has three requirements:
Staff network: 100 devices.
CCTV network: 50 devices.
Server network: 20 devices.
You could allocate:
| Department | Subnet size | Conventional usable hosts |
|---|---|---|
| Staff | /25 | 126 |
| CCTV | /26 | 62 |
| Servers | /27 | 30 |
This is called Variable Length Subnet Masking (VLSM) : using different prefix lengths within an address allocation to meet different requirements.
For example, these three networks can fit inside 192.168.10.0/24:
Staff:
192.168.10.0/25— addresses.0–.127.CCTV:
192.168.10.128/26— addresses.128–.191.Servers:
192.168.10.192/27— addresses.192–.223.
The remaining range, .224–.255, is available for future allocation if needed.
The networks do not overlap, and each begins at a valid subnet boundary.
4. Practical Linux demonstration
On Kali Linux, you can inspect your current interface configuration:
ip -4 addr show
ip routeYou can also install and use Python's built-in ipaddress module to calculate subnet information:
import ipaddressnetwork = ipaddress.ip_network("192.168.50.130/26", strict=False)print("Network:", network.network_address)print("Mask:", network.netmask)print("Broadcast:", network.broadcast_address)print("First host:", next(network.hosts()))print("Usable hosts:", network.num_addresses - 2)Expected results include:
Network: 192.168.50.128
Mask: 255.255.255.192
Broadcast: 192.168.50.191
First host: 192.168.50.129
Usable hosts: 62This is a useful way to check your manual calculations while learning. On point-to-point /31 networks and /32 routes, host-count assumptions need to be adjusted.
Final revision: Test your understanding
Try these questions without looking back at the lessons. You can select an answer and check it immediately.
10-question networking quiz
0/10 answered
1. How many bits are in an IPv4 address?
16 bits
32 bits
64 bits
128 bits
2. Which of these is an RFC1918 private address?
172.15.1.10
172.20.1.10
172.32.1.10
169.254.1.10
3. What is the subnet mask for /27?
255.255.255.0
255.255.255.128
255.255.255.224
255.255.255.240
4. What is the broadcast address of 192.168.1.64/26?
192.168.1.63
192.168.1.127
192.168.1.128
192.168.1.255
5. What does 127.0.0.1 normally represent?
Default gateway
Public IP address
Local loopback
Multicast group
6. How many conventional usable host addresses are in a /28 subnet?
6
14
16
30
7. Which destination is the IPv4 limited broadcast address?
0.0.0.0
127.0.0.1
255.255.255.255
224.0.0.1
8. A host has address 192.168.1.10/24. Which is its subnet's network address?
192.168.1.10
192.168.1.1
192.168.1.0
192.168.1.255
9. Which is a valid conventional contiguous subnet mask?
255.0.255.0
255.255.240.0
255.255.10.0
255.255.255.250
10. What is the primary purpose of a subnet mask?
Encrypt IP packets
Identify network and host bits
Assign a MAC address
Translate private addresses to public addresses
Check my answers
What you should master before moving on
You have covered all 15 topics, from IP addressing basics through CIDR and subnet calculations. Before progressing to routing, VLANs or AWS VPC networking, make sure you can do these five things without a calculator:
Convert an IPv4 octet between decimal and binary.
Recognise the three RFC1918 private ranges.
Explain the difference between a network address, host address and broadcast address.
Calculate subnet ranges for
/24,/25,/26,/27and/28.Explain why two devices on different IP subnets generally need a router to communicate.
My recommendation: Spend extra time on subnet masks and CIDR. Those are the foundations for designing networks, configuring routers, understanding AWS VPC subnets and troubleshooting connectivity problems.