From point A to point B
Point A: you already split the network into VLANs and know that each VLAN is a subnet, but IP addresses still look like loose numbers to you. Point B: by the end you will read an IPv4 address in binary, work out in seconds the network, broadcast and host range of any prefix, design a VLSM plan, configure it on routers and switches and verify it on the PC.
This chapter covers three topics of the Network Fundamentals domain of the v1.1 exam, worth 20%: 1.6 (configure and verify IPv4 addressing and subnetting), 1.7 (describe private IPv4 addressing) and 1.10 (verify IP parameters for client operating systems: Windows, macOS and Linux).
IPv4 and its header
IPv4 is the layer 3 protocol that identifies each device with a logical address and carries packets from one network to another. It allows hierarchical addressing (network and host), can be used with or without classes and lives today alongside IPv6.
The fields of the IPv4 header. Diagram: The House of Routing.
The header is 20 bytes long without options (it can reach 60). The fields you will use most:
| Field | What it is for |
|---|---|
| Version | It is 4 in IPv4 |
| IHL | Header length, in 4-byte words (5 = 20 bytes) |
| DSCP · ECN | Quality of service marking and congestion notification |
| Total Length | Total packet size, header plus data |
| Identification, Flags, Fragment Offset | Allow a packet to be fragmented and put back together |
| TTL | Each router subtracts 1; if it reaches 0, the packet is dropped and ICMP reports it. That way no packet loops forever. |
| Protocol | What it carries inside: 1 = ICMP, 6 = TCP, 17 = UDP, 89 = OSPF |
| Header Checksum | Checks for errors in the header only |
| Source and Destination Address | The source and destination IP addresses, 32 bits each |
32 bits and binary conversion
An IPv4 address has 32 bits. To make it easier to read, it is split into 4 groups of 8 bits called octets (or bytes), and each octet is written in decimal, separated by a dot. This is dotted decimal notation: 192.168.10.37.
The same address in decimal and in binary. Diagram: The House of Routing.
In decimal each position is worth a power of 10 (hundreds, tens, units). In binary each position is worth a power of 2. In an octet, from left to right: 128, 64, 32, 16, 8, 4, 2 and 1. With all 8 bits on you get 255, the maximum value of an octet.
From decimal to binary
Go through the values from left to right. If the number you have left is greater than or equal to the value, write a 1 and subtract it; if not, write a 0.
| Decimal | Sum | Binary |
|---|---|---|
| 168 | 128 + 32 + 8 | 10101000 |
| 172 | 128 + 32 + 8 + 4 | 10101100 |
| 37 | 32 + 4 + 1 | 00100101 |
| 240 | 128 + 64 + 32 + 16 | 11110000 |
To go from binary to decimal, add the values of the positions that hold a 1: 00011110 = 16 + 8 + 4 + 2 = 30.
For your notes. Write the row 128 · 64 · 32 · 16 · 8 · 4 · 2 · 1 on the exam’s blank sheet before you start. It saves you time on every subnetting question.
Address classes
Every address has two parts: the network ID, which identifies the segment, and the host ID, which identifies the device inside that segment. It is like a phone number: the area code points to the zone and the rest to the line. Inside one network no two hosts can share the same ID.
In the original classful scheme, the value of the first octet decides how many octets belong to the network and how many to the host:
Classes A, B and C, multicast and experimental. Diagram: The House of Routing.
| Class | First octet | Leading bits | Default mask | Hosts per network |
|---|---|---|---|---|
| A | 1 to 126 | 0 | 255.0.0.0 (/8) | 16,777,214 |
| B | 128 to 191 | 10 | 255.255.0.0 (/16) | 65,534 |
| C | 192 to 223 | 110 | 255.255.255.0 (/24) | 254 |
| D | 224 to 239 | 1110 | Not applicable: multicast | — |
| E | 240 to 255 | 1111 | Not applicable: experimental | — |
0 and 127 are not assigned as class A networks: 0.0.0.0/8 means “this network” and 127.0.0.0/8 is loopback (127.0.0.1 is the device itself). The address 255.255.255.255 is the limited broadcast, which does not cross routers.
Today the internet works classless: the mask or prefix says where the network ends, whatever the first octet. Even so, the exam still asks about classes and their default masks.
Private and special ranges
RFC 1918 reserves three blocks for private use. Any home or company can use them without asking permission, because they are not routed on the internet. To reach the internet, a router or firewall translates those addresses to a public one with NAT (or with PAT, which shares a single public IP).
The three private blocks and other ranges you should recognize. Diagram: The House of Routing.
| Block | Range | Use |
|---|---|---|
| 10.0.0.0/8 | 10.0.0.0 to 10.255.255.255 | Private (RFC 1918): large networks |
| 172.16.0.0/12 | 172.16.0.0 to 172.31.255.255 | Private (RFC 1918) |
| 192.168.0.0/16 | 192.168.0.0 to 192.168.255.255 | Private (RFC 1918): very common in homes and small offices (SOHO) |
| 127.0.0.0/8 | 127.0.0.0 to 127.255.255.255 | Loopback: the device itself |
| 169.254.0.0/16 | 169.254.0.0 to 169.254.255.255 | Link-local (APIPA, RFC 3927): the device assigns it to itself when it cannot get DHCP |
| 100.64.0.0/10 | 100.64.0.0 to 100.127.255.255 | Shared space for provider NAT (CGN, RFC 6598) |
| 192.0.2.0/24 · 198.51.100.0/24 · 203.0.113.0/24 | — | Documentation and examples (RFC 5737) |
Mask and prefix
The subnet mask separates the network ID from the host ID. It is a continuous run of ones (the network part) followed by zeros (the host part). The PC and the router use it to decide whether a destination is on their own network or whether the packet must go to the default gateway.
Because the ones are always contiguous, a mask octet can only be 0, 128, 192, 224, 240, 248, 252, 254 or 255. The same mask is also written as a prefix: a slash and the number of ones. 255.255.255.0 is /24.
| Prefix | Mask | Host bits | Addresses | Usable hosts |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 8 | 256 | 254 |
| /25 | 255.255.255.128 | 7 | 128 | 126 |
| /26 | 255.255.255.192 | 6 | 64 | 62 |
| /27 | 255.255.255.224 | 5 | 32 | 30 |
| /28 | 255.255.255.240 | 4 | 16 | 14 |
| /29 | 255.255.255.248 | 3 | 8 | 6 |
| /30 | 255.255.255.252 | 2 | 4 | 2 |
| /20 | 255.255.240.0 | 12 | 4096 | 4094 |
| /16 | 255.255.0.0 | 16 | 65,536 | 65,534 |
The host formula is 2h − 2, where h is the number of host bits. Two are subtracted because every network or subnet has two addresses that are not given to devices: the network address (all host bits 0) and the broadcast address (all host bits 1).
The AND operation
To find the network of an address, the device performs a bitwise logical AND between the IP and the mask. Only 1 AND 1 gives 1; 1 AND 0, 0 AND 1 and 0 AND 0 give 0. Where the mask has ones, the IP bit passes through; where it has zeros, it becomes 0.
192.168.0.100 AND 255.255.255.240 = 192.168.0.96. Diagram: The House of Routing.
Another example with a class B address: 150.150.2.1/24 AND 255.255.255.0 gives 150.150.2.0, so that host is on subnet 150.150.2.0/24. A PC uses this result to decide: if the destination’s network equals its own, it delivers the packet directly (with ARP); if it is different, it sends it to its default gateway.
Creating subnets
A subnet is a part of a major network. You create it by borrowing bits from the host portion and adding them to the network portion: the mask grows to the right by as many bits as you borrow. The goal is to split one large network into smaller ones, one per segment (one per VLAN, one per router-to-router link).
Four borrowed bits turn a /24 into 16 /28 subnets. Diagram: The House of Routing.
With n borrowed bits you get 2n subnets; with the h bits left for hosts, 2h − 2 hosts per subnet. In the example, 192.168.0.0/24 with 4 borrowed bits gives 16 /28 subnets of 14 hosts:
| Subnet | Network | First host | Last host | Broadcast |
|---|---|---|---|---|
| 1 | 192.168.0.0 | 192.168.0.1 | 192.168.0.14 | 192.168.0.15 |
| 2 | 192.168.0.16 | 192.168.0.17 | 192.168.0.30 | 192.168.0.31 |
| 3 | 192.168.0.32 | 192.168.0.33 | 192.168.0.46 | 192.168.0.47 |
| … | … | … | … | … |
| 16 | 192.168.0.240 | 192.168.0.241 | 192.168.0.254 | 192.168.0.255 |
How to choose the prefix: if you need S subnets, find the smallest n with 2n ≥ S. If you need H hosts per subnet, find the smallest h with 2h − 2 ≥ H. For example, 6 subnets need 3 bits (8 subnets); 50 hosts need 6 host bits (62 hosts), that is, a /26.
The magic number
On the exam you have no time to convert everything to binary. This method gives you the network, broadcast and host range in seconds:
- Find the interesting octet: the first one in the mask that is not 255.
- Work out the magic number: 256 minus the value of that octet. It is the size of each block.
- Count in multiples of the magic number and place the IP’s value in that octet. The multiple immediately below (or equal) is the network.
- The broadcast is the next network minus 1. The first host is the network + 1 and the last, the broadcast − 1.
192.168.0.100/28 falls in the block that starts at 96. Diagram: The House of Routing.
Example 1: 192.168.0.100/28. Mask 255.255.255.240, magic number 256 − 240 = 16. Blocks: 0, 16, 32, 48, 64, 80, 96, 112… 100 falls between 96 and 112. Network 192.168.0.96, first host .97, last .110, broadcast .111.
Example 2, in the third octet: 172.16.45.14/20. Mask 255.255.240.0; the interesting octet is the third and the magic number is 256 − 240 = 16. 45 falls between 32 and 48. Network 172.16.32.0, broadcast 172.16.47.255, first host 172.16.32.1, last 172.16.47.254. That is 212 − 2 = 4094 hosts.
/31, /32 and ip subnet-zero
Subnet zero (the first one, with the subnet bits at 0) and the all-ones subnet (the last one) used to be avoided in older networks. In Cisco IOS the ip subnet-zero command allows subnet zero and has been on by default since IOS 12.0, so today you count every subnet: 2n, without subtracting two. If a question states no ip subnet-zero or refers to old classful networks, use 2n − 2 for the subnets.
| Prefix | Typical use |
|---|---|
| /30 | Classic point-to-point link between two routers: 4 addresses, 2 hosts |
| /31 | Point-to-point link with no network or broadcast address (RFC 3021): both addresses are usable. IOS accepts it on point-to-point links and it saves half the addresses. |
| /32 | A single address: loopback interfaces and host routes |
R1(config)# interface gigabitethernet0/1
R1(config-if)# ip address 10.0.0.0 255.255.255.254
% Warning: use /31 mask on non point-to-point interface cautiously
R1(config-if)# interface loopback0
R1(config-if)# ip address 1.1.1.1 255.255.255.255
VLSM
With fixed-size subnets, every segment gets the same block: a link between two routers would waste 14 addresses of a /28 to use 2. VLSM (variable length subnet mask) lets you use different prefixes inside the same major network and give each segment only what it needs.
A /24 split into a /25, a /26, a /27 and two /30s. Diagram: The House of Routing.
The method:
- Sort the segments from the most hosts to the fewest.
- For each one, choose the smallest prefix that is enough (2h − 2 ≥ hosts).
- Assign the block at the first free address that is a multiple of its size.
| Segment | Hosts | Prefix | Network | Host range | Broadcast |
|---|---|---|---|---|---|
| LAN A | 100 | /25 | 192.168.1.0 | .1 to .126 | .127 |
| LAN B | 50 | /26 | 192.168.1.128 | .129 to .190 | .191 |
| LAN C | 20 | /27 | 192.168.1.192 | .193 to .222 | .223 |
| WAN 1 | 2 | /30 | 192.168.1.224 | .225 to .226 | .227 |
| WAN 2 | 2 | /30 | 192.168.1.228 | .229 to .230 | .231 |
192.168.1.232 to .255 are left free to grow. For networks with different masks to be advertised correctly, you need classless routing protocols (OSPF, EIGRP, RIPv2), which send the mask with every route.
CIDR and summarization
CIDR (Classless Inter-Domain Routing, RFC 4632) allocates blocks with any prefix, ignoring the boundaries of classes A, B and C. It was born in the 1990s to slow IPv4 exhaustion and the growth of internet routing tables. Together with NAT and private addresses, it is what kept IPv4 alive while IPv6 arrives.
CIDR also allows summarization (or supernetting): advertising several contiguous networks with a single route. To summarize, find how many leading bits they share:
| Network | Third octet in binary |
|---|---|
| 172.16.0.0/24 | 00000000 |
| 172.16.1.0/24 | 00000001 |
| 172.16.2.0/24 | 00000010 |
| 172.16.3.0/24 | 00000011 |
The 16 bits of the first two octets and the first 6 of the third match: 16 + 6 = 22. The summary route is 172.16.0.0/22. Benefits of CIDR: better use of the IPv4 space, smaller routing tables and less work for routers.
Configuring IPv4 in Cisco IOS
On a router, each connected interface is a different network. You configure it with ip address and enable it with no shutdown, because router interfaces come shut down.
R_CCS_01(config)# interface fastethernet0/0
R_CCS_01(config-if)# description Conexion a LAN de Caracas
R_CCS_01(config-if)# ip address 172.16.0.1 255.255.255.0
R_CCS_01(config-if)# no shutdown
R_CCS_01(config-if)# interface serial0/0/0
R_CCS_01(config-if)# description Conexion a S0/0/0 de R_MIA_01
R_CCS_01(config-if)# ip address 172.16.1.1 255.255.255.0
R_CCS_01(config-if)# no shutdown
R_CCS_01(config-if)# interface loopback0
R_CCS_01(config-if)# ip address 1.1.1.1 255.255.255.0
R_CCS_01(config-if)# end
R_CCS_01# copy running-config startup-config
You can put more than one network on the same interface with ip address … secondary. On a layer 2 switch the IP is for management only: it goes on an SVI, and the switch needs a default gateway to answer from other networks.
SW_CCS_01(config)# interface vlan 1
SW_CCS_01(config-if)# ip address 172.16.0.2 255.255.255.0
SW_CCS_01(config-if)# no shutdown
SW_CCS_01(config-if)# exit
SW_CCS_01(config)# ip default-gateway 172.16.0.1
On a layer 3 switch you enable ip routing and use one SVI per VLAN or routed ports with no switchport, as you saw in chapter 3. To verify:
R_CCS_01# show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 172.16.0.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial0/0/0 172.16.1.1 YES manual up up
Serial0/1/0 172.16.7.1 YES manual up up
Loopback0 1.1.1.1 YES manual up up
R_CCS_01# show ip route connected
C 172.16.0.0/24 is directly connected, FastEthernet0/0
C 172.16.1.0/24 is directly connected, Serial0/0/0
R_CCS_01# ping 172.16.1.2
!!!!!
Success rate is 100 percent (5/5)
Read the states like this: administratively down means no shutdown is missing; up/down points to a layer 1 or 2 problem (cable, encapsulation, the far end); up/up is what you want. show ip interface g0/0 also shows the mask and the broadcast address.
Verifying on Windows, macOS and Linux
Exam topic 1.10 asks you to verify IP parameters on the user’s device. On all three systems you look for the same things: IP address, mask or prefix, default gateway, DNS servers and whether the address came from DHCP.
| System | IP and mask | Default gateway | DNS |
|---|---|---|---|
| Windows | ipconfig · ipconfig /all | ipconfig · route print | ipconfig /all · nslookup |
| macOS | ifconfig en0 · ipconfig getifaddr en0 | netstat -rn · route get default | scutil --dns |
| Linux | ip address show (or ip a) | ip route show | resolvectl status · cat /etc/resolv.conf |
C:\> ipconfig /all
Ethernet adapter Ethernet:
DHCP Enabled. . . . . . . . . . . : Yes
IPv4 Address. . . . . . . . . . . : 172.16.0.10(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 172.16.0.1
DNS Servers . . . . . . . . . . . : 172.16.0.100
$ ip address show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
inet 172.16.4.10/24 brd 172.16.4.255 scope global eth0
$ ip route show
default via 172.16.4.1 dev eth0
172.16.4.0/24 dev eth0 proto kernel scope link src 172.16.4.10
On Windows, ipconfig /release and ipconfig /renew ask the DHCP server for a new address. macOS shows the mask in hexadecimal in ifconfig (netmask 0xffffff00 is /24). On Linux, brd is the subnet’s broadcast address.
For your notes. Order to troubleshoot a PC: 1) does it have a valid IP or 169.254.x.x? 2) does the mask match the network’s? 3) is the default gateway in its subnet and does it answer ping? 4) is there DNS? 5) ping and tracert (on macOS and Linux, traceroute) toward the destination.
What you take away
- IPv4 uses 32 bits in 4 octets. The header is 20 bytes and the router decides with the destination IP.
- An octet’s values are 128, 64, 32, 16, 8, 4, 2 and 1: with them you convert between binary and decimal.
- Classes: A 1–126 (/8), B 128–191 (/16), C 192–223 (/24), D multicast, E experimental. 127 is loopback.
- Private (RFC 1918): 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. 169.254.0.0/16 means DHCP failed.
- Hosts per subnet: 2h − 2. Subnets: 2n with the borrowed bits.
- Network = IP AND mask. Magic number = 256 − interesting octet; broadcast = next network − 1.
- /30 for classic links, /31 with no network or broadcast (RFC 3021), /32 for loopbacks.
- VLSM: assign from the largest subnet to the smallest. CIDR summarizes contiguous networks, such as four /24s into a /22.
- In IOS:
ip address,no shutdown,show ip interface brief; on the layer 2 switch, an SVI andip default-gateway. - On the client:
ipconfig /all(Windows),ifconfigoripconfig getifaddr(macOS),ip aandip route(Linux).
In the next chapter you move into routers and routing: how a router uses these addresses and its routing table to carry each packet from one network to another.
Slides
These slides support the guided class: view them here, full screen, or download the PDF for your notes. Part 1 goes with videos 1 and 2; Part 2 with video 3; and Part 3 with videos 4 and 5.
Class videos
The videos are in Spanish. The translation of the videos is in development.
Each part of the chapter has its own video. Tap a card and the video opens right here, over the page; use the Close button or the Esc key to go back to where you were. Use them alongside the slides of the same part.
- Chapter 4 · Part 1IPv4 fundamentals: what it is and its headerWatch video
- Chapter 4 · Part 2IPv4 fundamentals: octets and binary conversionWatch video
- Chapter 4 · Part 3Configuring IPv4: /28 subnet planWatch video
- Chapter 4 · Part 4Configuring IPv4: layer 3 switchWatch video
- Chapter 4 · Part 5Configuring IPv4: VLANs and trunksWatch video
When you play a video, it loads from YouTube (no cookies until you open it). See the full playlist on YouTube.
Packet Tracer labs
The labs are in Spanish. The translation of the labs is in development.
Download each lab's files and open them with Cisco Packet Tracer. Tap the name to see the two downloads.
Lab 1IPv4 addressing across four branches
You configure the interfaces of routers R_CCS_01, R_MIA_01, R_NYC_01 and R_PARIS_01 (Caracas, Miami, New York and Paris) with the address, description and no shutdown given in each branch’s table on the 172.16.0.0 network, plus their loopback. You save with copy running-config startup-config, check with show running-config and test each link with ping. Console and enable password: gj123.
Chapter assessment
There are 100 single-choice questions, split into 10 tabs of 10. Each tab mixes every topic in the chapter and rises in level: questions 1 to 3 are low difficulty, 4 to 8 are medium and 9 to 10 are high.
We do not save your answers. They run in your browser and, if you close or reload the page, you start from zero. Getting it wrong here is the cheapest way to learn.
Additional resources
These links take you to official sites outside this portal. Use them to practice, go further and confirm what you learned.
To study and practice
- Cisco U.: Implementing and Administering Cisco Solutions (CCNA) pathu.cisco.com
- Cisco Learning Network: community, forums and study resourceslearningnetwork.cisco.com
- Cisco Packet Tracer at Networking Academynetacad.com
Exam and certification
- Official CCNA 200-301 v1.1 exam topics (PDF)learningcontent.cisco.com
- Official CCNA certification pagecisco.com
Standards and references
- RFC 791: Internet Protocol (IPv4)rfc-editor.org
- RFC 1918: Address Allocation for Private Internetsrfc-editor.org
- RFC 4632: Classless Inter-Domain Routing (CIDR)rfc-editor.org
- Cisco: Configure IP Addresses and Unique Subnets for New Userscisco.com
Source and credits. Chapter built from Jesús Espinoza’s “IPv4 addressing” notes and “IPv4” slides (CCNA 200-301, part 4), paraphrased, corrected, updated and aligned with the official CCNA 200-301 v1.1 exam topics. Text drafted with AI assistance; original diagrams by The House of Routing. Technical details were checked against official Cisco documentation and RFCs 791, 1918, 3021, 3927, 4632, 5737 and 6598.
