Learn / Stage 3: Networking and CCNA / Lesson 3.2

$ lesson 3.2 --track ccna --domain addressing

IP Addressing: IPv4 Subnetting, VLSM, Private Ranges, IPv6 Basics

Subnetting scares people because it is usually taught as magic. It is just counting in blocks. Learn the block size method, design a VLSM plan without overlaps, know which ranges are special, and get comfortable with IPv6, with a calculator that shows every bit.

  • Stage 3 Networking and CCNA
  • Level Beginner to intermediate
  • 70 min
  • 6 sections, quiz, lab

Start the lesson Jump to the lab

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
3.2.01

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).

Subnet calculator

Type any IPv4 address and prefix, or drag the slider. Purple bits are the network part, green bits are the host part.

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.

3.2.02

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.

  1. Find the interesting octet of the mask. For /26 the mask is 255.255.255.192.
  2. Block size = 256 minus that value: 256 minus 192 = 64. Subnets start at 0, 64, 128, 192 in that octet.
  3. Find the block that contains your address. 192.168.50.130 sits in the block starting at 128.
  4. 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 cheat sheet
PrefixMaskBlock sizeUsable hosts
/24255.255.255.0256 (whole octet)254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242
/20255.255.240.016 in the third octet4094

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.

3.2.03

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.

VLSM plan
SubnetNeedsSmallest fitNetworkUsable rangeBroadcast
LAN-A100/25 (126 hosts)192.168.50.0.1 to .126.127
LAN-B50/26 (62)192.168.50.128.129 to .190.191
LAN-C20/27 (30)192.168.50.192.193 to .222.223
R1 to R22/30 (2)192.168.50.224.225 to .226.227
VLSM plan for 192.168.50.0/24: a /25, a /26, a /27 and a /30, placed largest first with no overlapLAN-A /25.0 to .127LAN-B /26.128 to .191LAN-C /27.192 to .223/30 link .224 to .227free: .228 to .255192.168.50.0/24, biggest subnet first, each starting on its own block boundary
The same plan drawn as a line of 256 addresses. Going largest first guarantees every block lands on a boundary, and .228 to .255 stay free for growth.
3.2.04

Private, special and public addresses

Special IPv4 ranges
RangeWhat it is
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Private (RFC 1918). Not routed on the internet; reaching the internet needs NAT (lesson 3.10).
127.0.0.0/8Loopback: the device itself.
169.254.0.0/16Link-local (APIPA): a client that asked for DHCP and got no answer gives itself one of these.
100.64.0.0/10Shared 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/24Documentation (RFC 5737). Safe for examples, never used on real networks.
224.0.0.0/4Multicast, 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.

3.2.05

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
IPv6 address types
TypePrefixNotes
Global unicast2000::/3Routable on the internet, like a public IPv4 address.
Unique localfc00::/7 (used as fd00::/8)Private use inside an organisation.
Link-localfe80::/10Every IPv6 interface has one; never routed. Routers use them as next hops and gateways.
Multicastff00::/8One to many. ff02::1 is all nodes, ff02::2 all routers on the link.
Anycastfrom the unicast spaceSame 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)
3.2.06

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.

console: R1 (R1 addressing)

Missions 0/6

    Simplified IOS simulator in your browser. It teaches the commands; Packet Tracer and real gear have many more.

    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?

    Q2Which prefix gives exactly 2 usable hosts in the classic calculation?

    Q3You need 50 hosts. Smallest subnet?

    Q4Which address is private?

    Q5What is the recommended way (RFC 5952) to write 2001:0db8:0000:0000:0001:0000:0000:0001?

    Q6Which IPv6 type does every IPv6 interface have automatically?

    0 / 6

    Hands-on lab

    Cisco Packet Tracer lab45 minutessimulated network

    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.

    Topology and addressing

    Lab 3.2 topology: R1 serves LAN-A and LAN-B, R2 serves LAN-C, and R1 and R2 share a /30 linkGi0/0/0Gi0/0/2Gi0/0/1Gi0/0/1Gi0/0/0PC-A.10/25SW-AR1PC-B.140/26SW-BR2SW-CPC-C.200/27
    R1 serves LAN-A on Gi0/0/0 and LAN-B on Gi0/0/2, and links to R2 on Gi0/0/1. R2 serves LAN-C on Gi0/0/0.
    Addressing table
    DeviceInterfaceIPv4 address / prefixDefault gateway or note
    R1Gi0/0/0192.168.50.1/25, 2001:db8:acad:a::1/64, fe80::1LAN-A gateway
    R1Gi0/0/2192.168.50.129/26, 2001:db8:acad:b::1/64, fe80::1LAN-B gateway
    R1Gi0/0/1192.168.50.225/30, 2001:db8:acad:12::1/64link to R2
    R2Gi0/0/1192.168.50.226/30, 2001:db8:acad:12::2/64link to R1
    R2Gi0/0/0192.168.50.193/27, 2001:db8:acad:c::1/64, fe80::2LAN-C gateway
    PC-AFa0192.168.50.10/25gw .1, IPv6 by SLAAC
    PC-BFa0192.168.50.140/26gw .129, IPv6 by SLAAC
    PC-CFa0192.168.50.200/27gw .193, IPv6 by SLAAC
    1. 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 interfaces
    2. IPv6 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 R2
    3. See 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 brief

      Find FF:FE in the middle of the host part.

    4. Clients

      Set each PC's IPv4 statically and IPv6 to Automatic (SLAAC) in IP Configuration.

    5. 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::1
    6. Verify

      R1#show ip interface brief
      R1#show ipv6 interface brief
      R1#show ipv6 interface GigabitEthernet0/0/0
      R1#show ip route
      R1#show ipv6 route

      Then ping PC-C from PC-A over IPv4 and IPv6, and run ipconfig on 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 /all on 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.