IP Subnetting Tutorial (Classless) – With Interactive Examples and Simulation 53 min read
Q1. What is classless IP address?
Answer: Classless is also called IP subnetting. It divides classful network addresses into smaller networks (subnet). The rules are simple: – In classful addressing scheme, a 32 bit address is divided into Network ID and Host ID in 8-bIt boundary:
Class Network_ID Host_ID Examples……………..Leftmost_byte_range(a.b.c.d)
A……….8 bit……. 24 bit…..18.104.22.168, 22.214.171.124…………0~127
B………16 bit…… 16 bit……126.96.36.199, 188.8.131.52…..128~191
C……. 24 bit……… 8 bit…… 184.108.40.206, 220.127.116.11…192~223
– Classless IP allows more left bits for network ID (and fewer bits for host ID). The number of bits used by
network ID is called network mask. For example, a.b.c.d/m says “network ID is the leftmost m bit.” – Examples of classful and classless addresses:
IP address Mask Class? Network address Network ID Host ID Number of hosts in this network 18.104.22.168/8 /8 class A 22.214.171.124/8 100 4.5.6 16,777,216 126.96.36.199/16 /16 classless 188.8.131.52/16 100.4 5.6 65,536 184.108.40.206/24 /24 classless 220.127.116.11/24 100.4.5 6 256 18.104.22.168/25 /25 classless 22.214.171.124/25 126.96.36.199 6 128
Q2. Why classless?
Answer: Using fixed boundary to allocate bits for network ID and hosts ID results side effects: IP address starvation. Consider this example: A network has 100 computers to be connected to Internet. They are using a class C network 188.8.131.52/24. Then the network grows to 500 computers. It needs a class B network, say 184.108.40.206/16. However, 220.127.116.11/16 covers 65,536 class B IP addresses. This network only uses 500 of them. 65,036 IP addresses are wasted. This causes the shortage of IP address due classful addressing scheme’s fixed networ/host boundary. This problem can be solved by classless addressing. For example, 18.104.22.168/23 allows 512 host ID. It covers addresses 22.214.171.124~126.96.36.199).
Q3. How to subnetting and creates network ID crossing byte boundary?
Answer: Subnetting uses network mask to allocate leftmost bits for network ID. The rules are simple: – Start with a classful address (class A, B, or C). – Add more bits to the classful network ID bits. Class B uses leftmost 16 bits for network ID. Its mask is /16. With classless addressing, the network mask for class B derived network can be /16~.31. – For example,
188.8.131.52 is a class B network address. Its default mask is /16. It covers 65,536 addresses.
184.108.40.206/24 is a classless subnet derived from class B network. Its mask is /24 and contains 256 addresses.
220.127.116.11/25 is a classless subnet derived from a class B network. Its mask is /25 and has 128 addresses. The table below presents classful and classless addresses in binary form:
Network ID/Mask Binary form (32 bits) Network ID/class Number of host ID and range
– 18.104.22.168/16 is a class B address, network ID 150.1 (16 bit), contains 65,356 hosts, (22.214.171.124~126.96.36.199), Its binary presentation is 10010110. 00000001.00000000.00000000
– 188.8.131.52/24 is classless derived from class B, network ID 150.1.2 (24 bits), contains 256 host addresses (184.108.40.206~220.127.116.11 ). Its binary form is 10010110. 00000001.00000010.00000000.
– 18.104.22.168/25 is classless derived from class B, network ID is 22.214.171.124 (25 bit), contains 128 host addresses (126.96.36.199~188.8.131.52). its binary form is 10010110. 00000001.00000010.10000000
Q4. Can we subnetting to create 184.108.40.206/14? Answer: No. Subnetting starts with classful address scheme. 220.127.116.11 is a class B address (150 is within class B range: 128~191). Class B network mask is /16. Subnetting a class B network address can only use masks to reduce the size of network, or increase the mask. /16~/21 are allowed. /1~/15 are not allowed.
Q5. How does a router lookup a classless IP address?
Answer: Let’s use examples to explain router’s operations: 1) When R1 receives ping sent by Jack, it compares ping’s destination IP address (18.104.22.168/25) with destination networks listed in routing table.
– 22.214.171.124/8. 126.96.36.199/25’s left most 8 bit is 150, not 100. Not a match.
– 188.8.131.52/16. 184.108.40.206/25’s left most 16 bit is 150.1. It’s a match. R1 forwards ping to 220.127.116.11/16. 2) When R2 receives ping, it compares ping’s destination IP address (18.104.22.168/25) with routing table’s destination networks. -22.214.171.124/24: 126.96.36.199/25’s left most 24 bit is 150.1. 2, not 150.1.0. Not a match.
-188.8.131.52/24: 184.108.40.206/25’s left most 24 bit is 150.1. 2, not 150.1.1. Not a match.
-220.127.116.11/24: 18.104.22.168/25’s left most 24 bit is 150.1. 2. It’s a match. R2 forward ping to 22.214.171.124/24 network 3) When R3 receives ping, it compares ping’s destination IP address (126.96.36.199/25) with routing table. -188.8.131.52/25: 184.108.40.206/25’s left most 25 bit is 220.127.116.11 2, not 18.104.22.168, Not a match.
– 22.214.171.124/25: 126.96.36.199/25’s left most 25 bit is 188.8.131.52. A match. R3 forwards ping to Rose.
Note: This example is more clear if read together with topology from the companion simulation.
This article is the FAQ of an interactive simulation. You may get more clear concepts by playing the simulation with visualized topology, packets, table. It is located under External links.