Update 13. Subnetting (Part 1).md

This commit is contained in:
2026-05-03 21:27:05 +00:00
parent 2192228b84
commit bf3bc54857

View File

@@ -1,194 +1,178 @@
---
id: 1777840095-WYOD
aliases:
- Subnetting (Part 1)
tags:
- CCNA
---
* Subnetting (Part 1)
tags:
* CCNA
# Subnetting (Part 1)
## IPV4 Address Classes
## IPv4 Address Classes
| Class |First octet | numeric range | Prefix Length |
| ----- | ---------- | ------------- |------------- |
| A |0xxxxxxxx | 0-127 | /8 |
| B |10xxxxxxx | 128-191 | /16 |
| C |110xxxxxx | 192-223 | /24 |
| D |1110xxxxx | 224-239 | |
| E |1111xxxxx | 240-255 | |
| Class | First Octet (Binary) | Range | Default Prefix |
| ----- | -------------------- | ------- | --------------- |
| A | 0xxxxxxx | 0127 | /8 |
| B | 10xxxxxx | 128191 | /16 |
| C | 110xxxxx | 192223 | /24 |
| D | 1110xxxx | 224239 | N/A (Multicast) |
| E | 1111xxxx | 240255 | N/A (Reserved) |
---
### Maximum Hosts per Network
## Maximum Hosts per Network
Host portion all 0s = Network address (network ID)
Host portion all 1s = broadcast address
* Host bits all **0s** Network address
* Host bits all **1s** → Broadcast address
192.168.1.0/24 -> 192.168.1.255/24
Host portion = 8 bits = 2^8 = 256
Maximum hosts per network = 2^8-2 = 254
### Example Calculations
**192.168.1.0/24 → 192.168.1.255**
172.16.0.0/16 -> 172.16.255.255/16
Host portion = 16 bits = 2^16 = 65,536
Maximum hosts per network = 2^16 -2 = 254
* Host bits: 8
* Total addresses: 2⁸ = 256
* Usable hosts: 256 2 = **254**
10.0.0.0/8 -> 10.255.255.255/8
Host portion = 24 bits = 2^24 = 16,777,216
Maximum hosts per network = 2^24 -2 = 16,777,214
**172.16.0.0/16 → 172.16.255.255**
### How IP addresses are distrubuted
* Host bits: 16
* Total addresses: 2¹⁶ = 65,536
* Usable hosts: 65,536 2 = **65,534**
- The [[IANA]] (Internet Assigned Numbers Authority) assigns IPV4 addresses/networks to
companies based on their size
- For example, a very large company might receive a class A or class B network, while a small
company might receive a ckass C network.
- However, this led to many wasted IP addresses.
**10.0.0.0/8 → 10.255.255.255**
#### Example 1
* Host bits: 24
* Total addresses: 2²⁴ = 16,777,216
* Usable hosts: 16,777,216 2 = **16,777,214**
+----+ +----+
| R1 |<----->| R2 |
+----+ ^ +----+
Point to Point network
- 256 addresses
- 1 network address (203.0.113.0)
- 1 broadcast address (203.0.113.255)
- 1 R1 address (203.0.113.1)
- 1 R2 address (203.0.113.2)
- **252 addresses Wasted**
---
## How IP Addresses Were Distributed
#### Example 2
* The **IANA (Internet Assigned Numbers Authority)** originally allocated IP ranges based on class.
* Large organizations received Class A or B networks, while smaller ones received Class C.
* This rigid system caused significant address waste.
Company X needs IP addressing for 5000 end hosts.
- A class C network does not provide enough addresses, so a class B network must be assigned
- This will result in about 6000 addresses being wasted.
### Example 1: Point-to-Point Link
## CIDR
Network: 203.0.113.0/24
- When the internet was first created, the creators did not predict that the internet
would become as large as it is today
- This resulted in wasted address space like the examples.
- The [[IETF]] introduced [[CIDR]] in 1993 to replace the 'classful' addressing system.
- With CIDR, the requirement of ...
- Class A = /8
- Class B = /16
- Class C = /24
were removed
- This allowed larger networks to be split into smaller networks, allowing greater efficiency
- These smaller networks are called 'subnetworks' or [[subnetting]]
* Total addresses: 256
* Used:
+----+ +----+
| R1 |<----->| R2 |
+----+ ^ +----+
203.0.113.0/24
* Network: 203.0.113.0
* Broadcast: 203.0.113.255
* R1: 203.0.113.1
* R2: 203.0.113.2
* **Unused: 252 addresses**
Network address
11001011.00000000.01110001.*00000000*
203 . 0 . 113 . 0
A tiny road, but a massive parking lot sitting empty.
Subnet Mask
11111111.11111111.11111111.*00000000*
255 . 255 . 255 . 0
---
2^8 - 2 = 254 usable addresses.
### Example 2: Company Needs 5000 Hosts
How many usable addreses are there in each network?
* Class C → too small (254 hosts)
* Class B → required (65,534 hosts)
* Result: ~60,000 unused addresses
#### CIDR /25
**203.0.113.0/25**
Network address:
11001011.00000000.01110001.0*0000000*
203 . 0 . 113 . 0
Subnet Mask
11111111.11111111.11111111.1*0000000*
255 . 255 . 255 . 128
*2^7 - 2 = 126 usable addresses*
---
#### CIDR /26
**203.0.113.0/26**
Network address
11001011.00000000.01110001.00*000000*
203 . 0 . 113 . 0
Subnet Mask
11111111.11111111.11111111.11*000000*
255 . 255 . 255 . 192
*2^6 - 2 = 62 usable addresses*
## CIDR (Classless Inter-Domain Routing)
#### CIDR /27
**203.0.113.0/27**
Network address
11001011.00000000.01110001.00*000000*
203 . 0 . 113 . 0
Subnet Mask
11111111.11111111.11111111.111*00000*
255 . 255 . 255 . 224
*2^5 - 2 = 30 usable addresses*
* Introduced by the **IETF (Internet Engineering Task Force)** in 1993
* Replaced classful addressing
* Removed fixed boundaries:
#### CIDR /28
**203.0.113.0/28**
Network address
11001011.00000000.01110001.00*000000*
203 . 0 . 113 . 0
Subnet Mask
11111111.11111111.11111111.1111*0000*
255 . 255 . 255 . 240
*2^4 - 2 = 14 usable addresses*
* Class A = /8
* Class B = /16
* Class C = /24
#### CIDR /29
*203.0.113.0/29*
Network address
11001011.00000000.01110001.00000*000*
203 . 0 . 113 . 0
Subnet Mask
11111111.11111111.11111111.11111*000*
255 . 255 . 255 . 248
*2^4 - 2 = 6 usable addresses*
### Why CIDR Matters
#### CIDR /30
**203.0.113.0/30**
Network address
11001011.00000000.01110001.000000*00*
203 . 0 . 113 . 0
Subnet Mask
11111111.11111111.11111111.111111*00*
255 . 255 . 255 . 252
*2^4 - 2 = 6 usable addresses*
CIDR lets you carve networks like a careful sculptor instead of swinging a sledgehammer.
Large networks can be split into smaller, efficient subnets.
This is the perfect CIDR for our 2 router
---
The remaining addresses in the 20 203.0.113.0/24 address block (20 203.0.113.4 - 20 203.0.113.255)
are now available to be used in other subnets!
## Subnetting Example
#### CIDR /31
*203.0.113.0/31*
Base network: **203.0.113.0/24**
2^1 -2= 0 usable addresses
* Subnet mask: 255.255.255.0
* Usable hosts: **254**
but for our point to point connection we can utilisize it
no need for broadcast or network address
In cisco device however you get a systeme warning
---
## CIDR Subnet Breakdown
### /25
* Mask: 255.255.255.128
* Hosts: 2⁷ 2 = **126**
### /26
* Mask: 255.255.255.192
* Hosts: 2⁶ 2 = **62**
### /27
* Mask: 255.255.255.224
* Hosts: 2⁵ 2 = **30**
### /28
* Mask: 255.255.255.240
* Hosts: 2⁴ 2 = **14**
### /29
* Mask: 255.255.255.248
* Hosts: 2³ 2 = **6**
### /30
* Mask: 255.255.255.252
* Hosts: 2² 2 = **2**
✔ Ideal for point-to-point links (e.g., router-to-router)
---
### /31
* Hosts: 2¹ 2 = 0 (traditionally)
However:
* Used for point-to-point links
* No network or broadcast needed
Cisco warning example:
```cisco
Router(config-if)# ip address 203.0.113.0 255.255.255.254
Warning use /31 mask on non point-to-pint interface cautiously
Warning: use /31 mask on non point-to-point interface cautiously
```
The remaining addresses in the 20 203.0.113.0/24 address block (20 203.0.113.2 - 203.0.113.255)
are now available to be used in other network!
---
### /32
#### CIDR /32
*203.0.113.0/32*
* Hosts: 2⁰ 2 = 1 (conceptually)
2^1 -2= -1 usable addresses
Used for:
can be used in static routes
don't worry about them now
* Loopbacks
* Static routes
* Identifying a single host
## Review
---
- [[CIDR]] (Classless Inter-Domain Routing)
- The process of subnetting
## Key Takeaways
* CIDR enables flexible and efficient IP allocation
* Subnetting reduces waste and improves scalability
* Smaller subnets = better utilization of address space