Learn subnetting concepts, CIDR notation, static routing, and dynamic routing using RIP. Understand how to divide networks and configure routing protocols.
Subnetting = breaking a bigger network into smaller networks.
An IPv4 address has two parts: Network Portion | Host Portion
Subnet mask tells which part is network.
Example:
IP: 192.168.10.0
Default mask (Class C): 255.255.255.0
Meaning:
Network = 192.168.10
Host range = last octet (0–255)
| Class | Range | Network Bits | Hosts |
|---|---|---|---|
| A | 1–126 | 8 bits | 16 million hosts |
| B | 128–191 | 16 bits | 65,000 hosts |
| C | 192–223 | 24 bits | 254 hosts |
Class C is smallest; often used in labs.
Subnetting cuts host portion into smaller pieces.
Number of Subnets = 2ⁿ
(where n = borrowed bits)
Hosts per Subnet = 2ʰ – 2
(where h = remaining host bits)
Given:
Network: 200.100.50.0
Required: 7 subnets
2³ = 8 ≥ 7 → borrow 3 bits
Default mask = 255.255.255.0
Borrow 3 bits → add (128+64+32) = 224
So new mask: 255.255.255.224 (/27)
224 subnet → increment = 32
(256 – 224 = 32)
| Subnet | Network | Range | Broadcast |
|---|---|---|---|
| 1 | 200.100.50.0 | 1–30 | .31 |
| 2 | .32 | 33–62 | 63 |
| 3 | .64 | 65–94 | 95 |
| 4 | .96 | 97–126 | 127 |
| 5 | .128 | 129–158 | 159 |
| 6 | .160 | 161–190 | 191 |
| 7 | .192 | 193–222 | 223 |
| 8 | .224 | 225–254 | 255 |
You used 7, so first seven are used.
Practice subnetting calculations in real-time!
Given: Network 192.168.1.0/24, need 24 usable hosts per subnet
We need 24 usable hosts → 2ʰ - 2 ≥ 24
2⁵ - 2 = 30 ≥ 24 → need 5 host bits
Original: /24 (255.255.255.0)
Host bits needed: 5 → Network bits: 32 - 5 = 27
New mask: /27 (255.255.255.224)
| Subnet | Network ID | Usable Range | Broadcast | Total Hosts |
|---|---|---|---|---|
| 1 | 192.168.1.0 | 192.168.1.1 - 192.168.1.30 | 192.168.1.31 | 30 |
| 2 | 192.168.1.32 | 192.168.1.33 - 192.168.1.62 | 192.168.1.63 | 30 |
| 3 | 192.168.1.64 | 192.168.1.65 - 192.168.1.94 | 192.168.1.95 | 30 |
Given: Network 172.16.0.0/16, need 10 usable hosts per subnet
We need 10 usable hosts → 2ʰ - 2 ≥ 10
2⁴ - 2 = 14 ≥ 10 → need 4 host bits
Original: /16 (255.255.0.0)
Host bits needed: 4 → Network bits: 32 - 4 = 28
New mask: /28 (255.255.255.240)
| Subnet | Network ID | Usable Range | Broadcast | Total Hosts |
|---|---|---|---|---|
| 1 | 172.16.0.0 | 172.16.0.1 - 172.16.0.14 | 172.16.0.15 | 14 |
| 2 | 172.16.0.16 | 172.16.0.17 - 172.16.0.30 | 172.16.0.31 | 14 |
| 3 | 172.16.0.32 | 172.16.0.33 - 172.16.0.46 | 172.16.0.47 | 14 |
Given: Network 10.0.0.0/8, need 120 usable hosts per subnet
We need 120 usable hosts → 2ʰ - 2 ≥ 120
2⁷ - 2 = 126 ≥ 120 → need 7 host bits
Original: /8 (255.0.0.0)
Host bits needed: 7 → Network bits: 32 - 7 = 25
New mask: /25 (255.255.255.128)
| Subnet | Network ID | Usable Range | Broadcast | Total Hosts |
|---|---|---|---|---|
| 1 | 10.0.0.0 | 10.0.0.1 - 10.0.0.126 | 10.0.0.127 | 126 |
| 2 | 10.0.0.128 | 10.0.0.129 - 10.0.0.254 | 10.0.0.255 | 126 |
| 3 | 10.0.1.0 | 10.0.1.1 - 10.0.1.126 | 10.0.1.127 | 126 |
Given: Network 192.168.100.0/24, need 2 usable hosts per subnet (for router links)
We need 2 usable hosts → 2ʰ - 2 ≥ 2
2² - 2 = 2 ≥ 2 → need 2 host bits
Original: /24 (255.255.255.0)
Host bits needed: 2 → Network bits: 32 - 2 = 30
New mask: /30 (255.255.255.252)
| Subnet | Network ID | Usable Range | Broadcast | Total Hosts |
|---|---|---|---|---|
| 1 | 192.168.100.0 | 192.168.100.1 - 192.168.100.2 | 192.168.100.3 | 2 |
| 2 | 192.168.100.4 | 192.168.100.5 - 192.168.100.6 | 192.168.100.7 | 2 |
| 3 | 192.168.100.8 | 192.168.100.9 - 192.168.100.10 | 192.168.100.11 | 2 |
CIDR allows any subnet mask, not just classful.
Instead of: 255.255.255.0
You can write: /24
Each / value tells how many NETWORK bits are used.
Example: 192.168.10.0/27
Means: 27 bits for network, 5 bits for hosts.
Static routing = manually adding routes.
Used when:
ip route <DESTINATION> <MASK> <NEXT-HOP>
AD rates the trustworthiness of routing information. An integer from 0 to 255 is assigned. Lower is better (more trusted).
If a router learns two paths to the same network via different protocols, it chooses the one with the lowest AD.
| Route Source | Default AD |
|---|---|
| Connected Interface | 0 |
| Static Route | 1 |
| EIGRP | 90 |
| OSPF | 110 |
| RIP | 120 |
| External EIGRP | 170 |
| Unknown | 255 (Unreachable) |
Works by counting "hops" (jumps) to the destination. Best route = fewest hops. Example: RIP, IGRP.
Routers know the entire network topology map. They share connectivity details, not just routing tables. Example: OSPF.
Combines aspects of Distance Vector and Link State. Example: EIGRP.
Used for routing between Autonomous Systems (AS) on the internet. It records the sequence of ASes a route passes through. Example: BGP.
Dynamic routing protocols automatically update routing tables. They save time but use more CPU and bandwidth.
router rip
ver 2
network <network_id> !-- for all the connected networks
no auto-summary