Vlsm And Cidr Notation
Category: Network Fundamentals
Type: Network Concepts
Generated on: 2025-07-10 08:52:48
For: Network Engineering, Administration & Technical Interviews
VLSM and CIDR Notation Cheat Sheet
Section titled “VLSM and CIDR Notation Cheat Sheet”VLSM (Variable Length Subnet Masking): A subnetting technique that allows you to divide an IP address space into subnets of varying sizes. This maximizes IP address utilization by allocating smaller subnets to smaller networks and larger subnets to larger networks, preventing IP address waste.
CIDR (Classless Inter-Domain Routing): An IP addressing scheme that replaces the old classful addressing system (Class A, B, C). CIDR uses a single IP address and a mask (e.g., 192.168.1.0/24) to represent a block of IP addresses. It aggregates routes and reduces the size of routing tables, improving internet routing efficiency. The “/24” indicates the number of bits in the network portion of the address.
Why it’s important:
-
Efficient IP Address Usage: Prevents IP address exhaustion by allocating only the necessary addresses.
-
Simplified Routing: CIDR enables route aggregation, which reduces the size of routing tables and improves network performance.
-
Flexible Network Design: VLSM allows you to tailor subnets to the specific needs of different network segments.
-
Subnetting: Dividing a network into smaller, logical subnetworks.
-
Supernetting: Combining multiple smaller networks into a larger network (opposite of subnetting). Used in route aggregation.
-
Network Address: The first address in a subnet, used to identify the network.
-
Broadcast Address: The last address in a subnet, used to send messages to all devices on the subnet.
-
Usable Host Addresses: The IP addresses that can be assigned to devices on the network (excluding the network and broadcast addresses).
-
Subnet Mask: A 32-bit number that separates the network portion of an IP address from the host portion. (e.g., 255.255.255.0)
-
CIDR Notation: Represents the subnet mask as a prefix length (number of contiguous ‘1’ bits in the mask). (e.g., /24, /27, /30)
-
Block Size: The number of IP addresses in a subnet, calculated as 2^(32 - prefix length).
-
Route Aggregation: Combining multiple routes into a single route advertisement. This simplifies routing tables.
-
Discontiguous Subnets: Subnets that are not contiguous in the address space. VLSM can help manage these, but it’s less efficient for routing.
Terminology:
| Term | Definition |
|---|---|
| Network Address | The starting address of a network. All hosts on the network share this network address. |
| Broadcast Address | The ending address of a network. Packets sent to this address are received by all hosts on the network. |
| Usable Addresses | The range of addresses between the network address and the broadcast address. These are the addresses that can be assigned to individual hosts. |
| Prefix Length | The number of bits used for the network portion of the IP address. Determines the size of the network. Represented as a / followed by the number of bits (e.g., /24). |
| Subnet Mask | A 32-bit number used to identify the network and host portions of an IP address. Can be converted to and from prefix length. |
| Block Size | The total number of IP addresses in a subnet. Calculated as 2(32 - prefix length). |
| VLSM | Variable Length Subnet Masking - the practice of using different subnet masks within the same network space to better utilize IP addresses. |
| CIDR | Classless Inter-Domain Routing - an IP addressing scheme that replaced the old classful addressing system, allowing for more efficient allocation of IP addresses. It’s the foundation upon which modern internet routing is built. |
VLSM Step-by-Step:
- Determine Network Requirements: Identify the number of hosts required for each network segment.
- Order Subnets by Size: Sort the networks from largest to smallest based on host requirements.
- Start with the Largest Subnet: Subnet the address space to accommodate the largest subnet, ensuring enough addresses for growth.
- Continue Subnetting: Repeat the subnetting process for the remaining networks, using the remaining address space. Each subnet is carved out of the previously unused portion.
Example with ASCII Diagram:
Let’s say we have a network 192.168.1.0/24 and need to create three subnets:
- Subnet A: 60 hosts
- Subnet B: 30 hosts
- Subnet C: 10 hosts
Original Network: 192.168.1.0/24 (256 Addresses)
1. Subnet A (60 hosts): Needs /26 (64 addresses: 2^6 = 64) * Network: 192.168.1.0/26 (Addresses: 192.168.1.0 - 192.168.1.63) * Usable: 192.168.1.1 - 192.168.1.62 * Broadcast: 192.168.1.63
2. Subnet B (30 hosts): Needs /27 (32 addresses: 2^5 = 32) * Network: 192.168.1.64/27 (Addresses: 192.168.1.64 - 192.168.1.95) * Usable: 192.168.1.65 - 192.168.1.94 * Broadcast: 192.168.1.95
3. Subnet C (10 hosts): Needs /28 (16 addresses: 2^4 = 16) * Network: 192.168.1.96/28 (Addresses: 192.168.1.96 - 192.168.1.111) * Usable: 192.168.1.97 - 192.168.1.110 * Broadcast: 192.168.1.111
Remaining Address Space: 192.168.1.112 - 192.168.1.255CIDR Aggregation:
Consider these networks:
- 192.168.4.0/24
- 192.168.5.0/24
- 192.168.6.0/24
- 192.168.7.0/24
These can be aggregated into a single route: 192.168.4.0/22 (covers addresses 192.168.4.0 - 192.168.7.255)
CIDR to Subnet Mask Conversion:
- /24 = 255.255.255.0
- /25 = 255.255.255.128
- /26 = 255.255.255.192
- /27 = 255.255.255.224
- /28 = 255.255.255.240
- /29 = 255.255.255.248
- /30 = 255.255.255.252
- /31 = 255.255.255.254
- /32 = 255.255.255.255
Subnet Mask to CIDR Conversion:
Count the number of ‘1’s in the subnet mask’s binary representation.
Example: 255.255.255.0 = 11111111.11111111.11111111.00000000 = /24
CIDR and VLSM are addressing schemes, not protocols. They affect how IP addresses are assigned and used, which in turn impacts routing protocols.
-
Routing Protocols: BGP, OSPF, EIGRP, and RIP all support CIDR. They use CIDR notation to advertise routes and make routing decisions.
-
BGP (Border Gateway Protocol): Relies heavily on CIDR for route aggregation and to maintain a manageable routing table.
-
OSPF (Open Shortest Path First): Supports VLSM and CIDR. OSPF routers exchange Link State Advertisements (LSAs) that include network prefixes and subnet masks.
-
EIGRP (Enhanced Interior Gateway Routing Protocol): Also supports VLSM and CIDR. EIGRP uses a composite metric to determine the best path to a destination network.
Example: OSPF LSA:
An OSPF router advertises a network using an LSA. The LSA will include the Network Address and the Subnet Mask (or Prefix Length).
Router#show ip ospf database network 192.168.1.0
OSPF Router with ID (10.1.1.1) (Process ID 1)
Link connected to: another Router (Transit Network) (Link ID) Designated Router address: 192.168.1.1 (Link Data) Router Interface address: 192.168.1.2 Number of TOS metrics: 0 TOS 0 Metrics: 10
OSPF Router with ID (10.1.1.2) (Process ID 1)
Link connected to: a Stub Network (Link ID) Network/subnet number: 192.168.1.0 (Link Data) Network Mask: 255.255.255.0 Number of TOS metrics: 0 TOS 0 Metrics: 10In this example, the Network Mask: 255.255.255.0 indicates the subnet mask for the network 192.168.1.0, which is equivalent to /24.
- Enterprise Network: A company has multiple departments (Sales, Marketing, Engineering). VLSM can be used to allocate appropriate subnet sizes for each department, based on the number of employees and devices in each department.
- ISP (Internet Service Provider): ISPs use CIDR to aggregate routes and advertise a smaller number of routes to the internet backbone. This reduces the size of the global routing table.
- Data Center: Data centers use VLSM to create small subnets for server clusters, load balancers, and other infrastructure components. This improves security and manageability.
- Home Network: While less complex, VLSM principles can be applied even in a home network with multiple VLANs for different devices (IoT, Guest network, etc.).
- Cloud Computing: Cloud providers rely heavily on CIDR and VLSM to manage their vast IP address spaces and allocate resources efficiently to customers.
Example: ISP Route Aggregation:
An ISP has the following customer networks:
- 203.0.113.0/24
- 203.0.114.0/24
- 203.0.115.0/24
- 203.0.116.0/24
Instead of advertising each /24 network individually, the ISP can aggregate these into a single route: 203.0.112.0/22. This significantly reduces the number of routes advertised to upstream providers.
- Incorrect Subnet Mask: Using the wrong subnet mask can lead to IP address conflicts, network connectivity problems, and routing issues.
- Overlapping Subnets: Creating overlapping subnets can cause unpredictable network behavior. Careful planning is essential.
- IP Address Exhaustion: Poor IP address management can lead to IP address exhaustion, preventing new devices from connecting to the network.
- Routing Loops: Incorrect route aggregation or subnetting can create routing loops, where packets are forwarded endlessly between routers.
- MTU (Maximum Transmission Unit) Issues: VLSM can sometimes expose MTU issues if different subnets have different MTU configurations. This can lead to fragmentation and performance problems.
Troubleshooting Tips:
- Ping: Use the
pingcommand to test basic network connectivity. If ping fails, check the IP address configuration and subnet mask. - Traceroute: Use the
traceroutecommand to trace the path of packets to a destination. This can help identify routing problems. ipconfig(Windows) /ifconfig(Linux/macOS): Use these commands to display the IP address configuration of a device.show ip route(Cisco): Use this command on a Cisco router to display the routing table. Verify that the routing table contains the correct routes.- Packet Capture: Use tools like Wireshark to capture and analyze network traffic. This can help identify addressing or routing issues.
Example: Troubleshooting a Subnet Mask Issue:
A host with IP address 192.168.1.10 and subnet mask 255.255.255.0 cannot communicate with a host with IP address 192.168.1.20 and subnet mask 255.255.255.192.
- Reason: The subnet masks are different. 192.168.1.10/24 and 192.168.1.20/26 are in different subnets.
- Solution: Ensure both hosts are using the same subnet mask (e.g., 255.255.255.0 or 255.255.255.192), or reconfigure the network to use compatible subnets.
Cisco Router Configuration:
! Configure an interface with an IP address and subnet maskinterface GigabitEthernet0/0 ip address 192.168.1.1 255.255.255.0 no shutdown
! Configure OSPF with CIDR supportrouter ospf 1 network 192.168.1.0 0.0.0.255 area 0 ! The wildcard mask (0.0.0.255) is the inverse of the subnet mask (255.255.255.0) network 10.0.0.0 0.0.0.255 area 0
! Configure a static route with CIDR notationip route 172.16.0.0 255.255.0.0 Serial0/0/0
! Configure EIGRP with VLSM support (auto-summary disabled for VLSM)router eigrp 100 no auto-summary ! Important for VLSM network 192.168.1.0 0.0.0.255 network 10.0.0.0 0.0.0.255Linux Interface Configuration:
# Configure an interface with an IP address and CIDR notationsudo ip addr add 192.168.1.10/24 dev eth0
# Bring the interface upsudo ip link set eth0 up
# Display the IP address configurationip addr show eth0Windows Interface Configuration:
(GUI - Network Connections -> Properties -> IPv4 Properties)
- IP Address: 192.168.1.10
- Subnet Mask: 255.255.255.0
- Default Gateway: 192.168.1.1
(Command Line - netsh)
netsh interface ip set address name="Ethernet" static 192.168.1.10 255.255.255.0 192.168.1.11. What is VLSM, and why is it important?
- VLSM stands for Variable Length Subnet Masking. It is a subnetting technique that allows you to divide an IP address space into subnets of varying sizes. It’s important because it maximizes IP address utilization by allocating smaller subnets to smaller networks and larger subnets to larger networks, preventing IP address waste.
2. What is CIDR, and how does it differ from classful addressing?
- CIDR stands for Classless Inter-Domain Routing. It’s an IP addressing scheme that uses a single IP address and a mask (e.g., 192.168.1.0/24) to represent a block of IP addresses. It differs from classful addressing (Class A, B, C) because it doesn’t rely on the first octet of the IP address to determine the network size. CIDR allows for more flexible allocation of IP addresses and enables route aggregation.
3. How do you calculate the number of usable host addresses in a subnet?
- The number of usable host addresses is calculated as 2(32 - prefix length) - 2. You subtract 2 because one address is reserved for the network address and one for the broadcast address.
4. Explain the difference between subnetting and supernetting.
- Subnetting is dividing a network into smaller, logical subnetworks. Supernetting is combining multiple smaller networks into a larger network (opposite of subnetting). Subnetting increases the number of networks, while supernetting decreases it.
5. How does CIDR help with route aggregation?
- CIDR allows multiple contiguous networks to be represented by a single, larger network address with a shorter prefix. This reduces the number of routes that need to be advertised, simplifying routing tables and improving network performance. For example, advertising 192.168.4.0/24, 192.168.5.0/24, 192.168.6.0/24, and 192.168.7.0/24 as 192.168.4.0/22.
6. What is the significance of the “/24” in the IP address 192.168.1.0/24?
- The “/24” indicates that the first 24 bits of the IP address (192.168.1) represent the network portion, and the remaining 8 bits represent the host portion. This means the subnet mask is 255.255.255.0.
7. Why is it important to disable auto-summary in EIGRP when using VLSM?
- Auto-summary in EIGRP automatically summarizes routes to classful boundaries (e.g., Class A, B, C). This can prevent EIGRP from correctly advertising the VLSM subnets, leading to routing problems. Disabling auto-summary ensures that EIGRP advertises the actual subnets with their correct masks.
8. You have the network 10.0.0.0/24. You need to create two subnets: one for 100 hosts and one for 50 hosts. What are the network addresses and subnet masks for these two subnets?
- Subnet 1 (100 hosts): Needs /25 (128 addresses). Network: 10.0.0.0/25 (255.255.255.128)
- Subnet 2 (50 hosts): Needs /26 (64 addresses). Network: 10.0.0.128/26 (255.255.255.192)
9. What are the network address, broadcast address, and usable IP range for the subnet 172.16.10.0/27?
- Network Address: 172.16.10.0
- Broadcast Address: 172.16.10.31
- Usable IP Range: 172.16.10.1 - 172.16.10.30
10. How would you determine the block size for a /29 subnet?
-
A /29 subnet has 29 bits for the network portion and 3 bits for the host portion (32 - 29 = 3). The block size is 23 = 8. Therefore, a /29 subnet has a block size of 8.
-
IPv6 Addressing: IPv6 uses a different addressing scheme with much larger address space. CIDR principles still apply, but the notation and calculations are different.
-
NAT (Network Address Translation): NAT allows multiple devices on a private network to share a single public IP address. VLSM is often used in conjunction with NAT to manage the private address space.
-
VLANs (Virtual LANs): VLANs allow you to segment a network logically, even if the devices are physically connected to the same switch. VLSM can be used to assign different IP address ranges to different VLANs.
-
DHCP (Dynamic Host Configuration Protocol): DHCP automatically assigns IP addresses, subnet masks, and other network configuration parameters to devices. DHCP servers are configured with the IP address ranges defined by VLSM.
-
IP Address Management (IPAM): IPAM software helps organizations manage their IP address space, track IP address assignments, and prevent IP address conflicts. It’s essential for managing large and complex networks that use VLSM.
Further Reading:
- RFC 1519: Classless Inter-Domain Routing (CIDR): an Address Assignment and Aggregation Strategy
- Cisco Documentation: IP Addressing and Subnetting for New Users
- Network Warrior by Gary A. Donhue: A practical guide to network administration.