By the end of this lesson you can
- Find the network, broadcast, host range and host count for any IPv4 prefix by hand
- Design a VLSM plan that fits several subnets into one block without overlap
- Name the private and special IPv4 ranges and what each means in an investigation
- Write, shorten and classify IPv6 addresses, and build an EUI-64 interface ID
- Configure and verify dual stack addressing on a router
IPv4 addresses, masks and prefixes
An IPv4 address is 32 bits, written as four decimal numbers (octets) from 0 to 255. The mask says how many of those bits name the network; the rest name the host. 255.255.255.0 and /24 say the same thing: 24 network bits, 8 host bits.
- Network address: all host bits 0. It names the subnet and cannot be given to a host.
- Broadcast address: all host bits 1. A packet to it reaches every host in the subnet.
- Usable hosts: 2host bits minus 2. A /24 gives 254, a /30 gives 2 (ideal for router to router links). A /31 gives two usable addresses on point to point links (RFC 3021), and a /32 is a single host.
- The wildcard mask is the mask inverted (0.0.0.255 for a /24). ACLs and OSPF use it (lessons 3.8 and 3.9).
Classful thinking (Class A, B, C) is history. Any prefix length can be used on any range, which is what CIDR (classless inter-domain routing) means.
Subnetting by hand: the block size method
You do not need a calculator, and in the exam you will not have one. Use the interesting octet, the one where the mask is not 255 or 0.
- Find the interesting octet of the mask. For /26 the mask is 255.255.255.192.
- Block size = 256 minus that value: 256 minus 192 = 64. Subnets start at 0, 64, 128, 192 in that octet.
- Find the block that contains your address. 192.168.50.130 sits in the block starting at 128.
- Network = 192.168.50.128. Broadcast = one less than the next block: 192.168.50.191. Hosts = .129 to .190, which is 62 hosts.
| Prefix | Mask | Block size | Usable hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 (whole octet) | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
| /20 | 255.255.240.0 | 16 in the third octet | 4094 |
Practise with the question button in the calculator above until you can do one in under 30 seconds. When the mask's interesting octet is the third one (for example /20), the same method applies to the third octet and the fourth octet runs from 0 to 255 inside each block.
VLSM: fitting different sized subnets into one block
Real networks need subnets of different sizes. Variable length subnet masking gives each one only the space it needs. The rule that keeps plans clean: allocate the biggest subnet first, and start every subnet on a multiple of its own block size.
The lab scenario: you are given 192.168.50.0/24 and need LAN-A with 100 hosts, LAN-B with 50, LAN-C with 20 and one router to router link.
| Subnet | Needs | Smallest fit | Network | Usable range | Broadcast |
|---|---|---|---|---|---|
| LAN-A | 100 | /25 (126 hosts) | 192.168.50.0 | .1 to .126 | .127 |
| LAN-B | 50 | /26 (62) | 192.168.50.128 | .129 to .190 | .191 |
| LAN-C | 20 | /27 (30) | 192.168.50.192 | .193 to .222 | .223 |
| R1 to R2 | 2 | /30 (2) | 192.168.50.224 | .225 to .226 | .227 |
Private, special and public addresses
| Range | What it is |
|---|---|
| 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | Private (RFC 1918). Not routed on the internet; reaching the internet needs NAT (lesson 3.10). |
| 127.0.0.0/8 | Loopback: the device itself. |
| 169.254.0.0/16 | Link-local (APIPA): a client that asked for DHCP and got no answer gives itself one of these. |
| 100.64.0.0/10 | Shared address space for carrier-grade NAT (RFC 6598). Many Indian mobile and broadband users sit behind it. |
| 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 | Documentation (RFC 5737). Safe for examples, never used on real networks. |
| 224.0.0.0/4 | Multicast, for example OSPF uses 224.0.0.5 and 224.0.0.6. |
Private does not mean secure. It only means internet routers will not carry those addresses; inside your network, a private address is just as reachable as any other. Security comes from filtering and segmentation, not from the address range.
IPv6: writing, shortening and address types
IPv6 addresses are 128 bits, written as eight groups of four hex digits. Two rules shorten them: drop the leading zeros in any group, and replace one run of all-zero groups with ::. Using :: twice would be ambiguous, so it is allowed only once.
# full form
2001:0db8:0000:0000:0000:ff00:0042:8329
# leading zeros dropped
2001:db8:0:0:0:ff00:42:8329
# longest zero run replaced
2001:db8::ff00:42:8329| Type | Prefix | Notes |
|---|---|---|
| Global unicast | 2000::/3 | Routable on the internet, like a public IPv4 address. |
| Unique local | fc00::/7 (used as fd00::/8) | Private use inside an organisation. |
| Link-local | fe80::/10 | Every IPv6 interface has one; never routed. Routers use them as next hops and gateways. |
| Multicast | ff00::/8 | One to many. ff02::1 is all nodes, ff02::2 all routers on the link. |
| Anycast | from the unicast space | Same address on many devices; the nearest one answers. |
There is no broadcast in IPv6. Hosts get addresses statically, by SLAAC (the router advertises the /64 prefix and the host builds its own interface ID), by stateless DHCPv6 (SLAAC plus DHCPv6 for options like DNS) or by stateful DHCPv6. With modified EUI-64, the interface ID comes from the MAC: split the 48 bit MAC in half, insert FFFE in the middle and flip the seventh bit of the first byte.
# MAC 0050.56ab.cdef
0050:56 | ab:cdef -> 0050:56ff:feab:cdef
# flip bit 7 of the first byte: 00 becomes 02
interface ID 0250:56ff:feab:cdef (written 250:56ff:feab:cdef)Configure the plan on a router, then check clients
Put the VLSM plan onto R1's three interfaces in the simulator, then add IPv6. On real devices and in Packet Tracer the commands are the same.
Missions 0/6
On clients, check what they actually got. Windows: ipconfig /all. Linux: ip addr and ip route. macOS: ifconfig, or networksetup -getinfo Wi-Fi where the service name matches your adapter (it differs between Macs).
Flashcards: do you remember?
Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.
Quick quiz
Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.
Q1What is the broadcast address of 192.168.50.130/26?
Blocks of 64: 128 to 191.
Q2Which prefix gives exactly 2 usable hosts in the classic calculation?
4 addresses minus network and broadcast. /31 also gives 2 on point-to-point links under RFC 3021.
Q3You need 50 hosts. Smallest subnet?
/26 gives 62; /27 gives only 30.
Q4Which address is private?
172.16.0.0/12 runs from 172.16 to 172.31.
Q5What is the recommended way (RFC 5952) to write 2001:0db8:0000:0000:0001:0000:0000:0001?
B and C are both valid addresses, but when two zero runs are equal, RFC 5952 compresses the first one. A and D use :: twice, which is never allowed.
Q6Which IPv6 type does every IPv6 interface have automatically?
fe80::/10 link-local addresses exist on every IPv6 enabled interface.
Hands-on lab
Packet Tracer lab 3.2: VLSM plan plus a dual stack link
You need: Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Devices: 2 x ISR4331, 3 x 2960, 3 x PC-PT. Work out the VLSM table yourself before you read the answer in section 3.
Simulator lab, zero risk. This lab runs inside Cisco Packet Tracer, so it touches no real network. Packet Tracer is free with a Cisco Networking Academy account (netacad.com). It simulates a subset of Cisco IOS, so where support for a feature is uncertain we say so instead of promising it works.
Topology and addressing
| Device | Interface | IPv4 address / prefix | Default gateway or note |
|---|---|---|---|
| R1 | Gi0/0/0 | 192.168.50.1/25, 2001:db8:acad:a::1/64, fe80::1 | LAN-A gateway |
| R1 | Gi0/0/2 | 192.168.50.129/26, 2001:db8:acad:b::1/64, fe80::1 | LAN-B gateway |
| R1 | Gi0/0/1 | 192.168.50.225/30, 2001:db8:acad:12::1/64 | link to R2 |
| R2 | Gi0/0/1 | 192.168.50.226/30, 2001:db8:acad:12::2/64 | link to R1 |
| R2 | Gi0/0/0 | 192.168.50.193/27, 2001:db8:acad:c::1/64, fe80::2 | LAN-C gateway |
| PC-A | Fa0 | 192.168.50.10/25 | gw .1, IPv6 by SLAAC |
| PC-B | Fa0 | 192.168.50.140/26 | gw .129, IPv6 by SLAAC |
| PC-C | Fa0 | 192.168.50.200/27 | gw .193, IPv6 by SLAAC |
IPv4 on every router interface
R1(config)#interface GigabitEthernet0/0/0 R1(config-if)#ip address 192.168.50.1 255.255.255.128 R1(config-if)#no shutdown ! repeat for Gi0/0/2 and Gi0/0/1, then R2's interfacesIPv6 routing and addresses
R1(config)#ipv6 unicast-routing R1(config)#interface GigabitEthernet0/0/0 R1(config-if)#ipv6 address 2001:db8:acad:a::1/64 R1(config-if)#ipv6 address fe80::1 link-local ! same pattern on the other interfaces and on R2See EUI-64 for yourself
R1(config)#interface loopback 0 R1(config-if)#ipv6 address 2001:db8:acad:99::/64 eui-64 R1(config-if)#end R1#show ipv6 interface briefFind
FF:FEin the middle of the host part.Clients
Set each PC's IPv4 statically and IPv6 to Automatic (SLAAC) in IP Configuration.
Routes so the LANs meet (a preview of lesson 3.7)
R1(config)#ip route 192.168.50.192 255.255.255.224 192.168.50.226 R1(config)#ipv6 route 2001:db8:acad:c::/64 2001:db8:acad:12::2 R2(config)#ip route 192.168.50.0 255.255.255.128 192.168.50.225 R2(config)#ip route 192.168.50.128 255.255.255.192 192.168.50.225 R2(config)#ipv6 route 2001:db8:acad:a::/64 2001:db8:acad:12::1 R2(config)#ipv6 route 2001:db8:acad:b::/64 2001:db8:acad:12::1Verify
R1#show ip interface brief R1#show ipv6 interface brief R1#show ipv6 interface GigabitEthernet0/0/0 R1#show ip route R1#show ipv6 routeThen ping PC-C from PC-A over IPv4 and IPv6, and run
ipconfigon PC-A: its IPv6 gateway should be R1's link-local fe80::1.
You are done when: All three LANs reach each other over IPv4 and IPv6, your own VLSM table matches the one in section 3, and you found the FFFE in the EUI-64 address.
Packet Tracer limits and notes
- Whether Packet Tracer PCs build their SLAAC interface ID with EUI-64 or a random value can vary by version. UNVERIFIED.
ipconfig /allon Packet Tracer PCs shows less detail than real Windows.- Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.
Download the lab checklist (.txt) Print it or keep it open beside Packet Tracer.
Key takeaways
- Block size = 256 minus the interesting mask octet.
- VLSM: biggest first, on block boundaries, no overlap.
- Private ranges need NAT to reach the internet, and are not a security control.
- IPv6: drop leading zeros, one :: only, link-local everywhere, no broadcast.
- Segmentation starts with a good addressing plan.
Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.