Update 13. Subnetting (Part 1).md
This commit is contained in:
@@ -1,194 +1,178 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
id: 1777840095-WYOD
|
id: 1777840095-WYOD
|
||||||
aliases:
|
aliases:
|
||||||
- Subnetting (Part 1)
|
|
||||||
|
* Subnetting (Part 1)
|
||||||
tags:
|
tags:
|
||||||
- CCNA
|
* CCNA
|
||||||
---
|
|
||||||
|
|
||||||
# Subnetting (Part 1)
|
# Subnetting (Part 1)
|
||||||
|
|
||||||
## IPV4 Address Classes
|
## IPv4 Address Classes
|
||||||
|
|
||||||
| Class |First octet | numeric range | Prefix Length |
|
| Class | First Octet (Binary) | Range | Default Prefix |
|
||||||
| ----- | ---------- | ------------- |------------- |
|
| ----- | -------------------- | ------- | --------------- |
|
||||||
| A |0xxxxxxxx | 0-127 | /8 |
|
| A | 0xxxxxxx | 0–127 | /8 |
|
||||||
| B |10xxxxxxx | 128-191 | /16 |
|
| B | 10xxxxxx | 128–191 | /16 |
|
||||||
| C |110xxxxxx | 192-223 | /24 |
|
| C | 110xxxxx | 192–223 | /24 |
|
||||||
| D |1110xxxxx | 224-239 | |
|
| D | 1110xxxx | 224–239 | N/A (Multicast) |
|
||||||
| E |1111xxxxx | 240-255 | |
|
| E | 1111xxxx | 240–255 | N/A (Reserved) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Maximum Hosts per Network
|
## Maximum Hosts per Network
|
||||||
|
|
||||||
Host portion all 0s = Network address (network ID)
|
* Host bits all **0s** → Network address
|
||||||
Host portion all 1s = broadcast address
|
* Host bits all **1s** → Broadcast address
|
||||||
|
|
||||||
192.168.1.0/24 -> 192.168.1.255/24
|
### Example Calculations
|
||||||
Host portion = 8 bits = 2^8 = 256
|
|
||||||
Maximum hosts per network = 2^8-2 = 254
|
|
||||||
|
|
||||||
|
**192.168.1.0/24 → 192.168.1.255**
|
||||||
|
|
||||||
172.16.0.0/16 -> 172.16.255.255/16
|
* Host bits: 8
|
||||||
Host portion = 16 bits = 2^16 = 65,536
|
* Total addresses: 2⁸ = 256
|
||||||
Maximum hosts per network = 2^16 -2 = 254
|
* Usable hosts: 256 − 2 = **254**
|
||||||
|
|
||||||
10.0.0.0/8 -> 10.255.255.255/8
|
**172.16.0.0/16 → 172.16.255.255**
|
||||||
Host portion = 24 bits = 2^24 = 16,777,216
|
|
||||||
Maximum hosts per network = 2^24 -2 = 16,777,214
|
|
||||||
|
|
||||||
### 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
|
**10.0.0.0/8 → 10.255.255.255**
|
||||||
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.
|
|
||||||
|
|
||||||
#### 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.
|
### Example 1: Point-to-Point Link
|
||||||
- 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.
|
|
||||||
|
|
||||||
## CIDR
|
Network: 203.0.113.0/24
|
||||||
|
|
||||||
- When the internet was first created, the creators did not predict that the internet
|
* Total addresses: 256
|
||||||
would become as large as it is today
|
* Used:
|
||||||
- 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]]
|
|
||||||
|
|
||||||
+----+ +----+
|
* Network: 203.0.113.0
|
||||||
| R1 |<----->| R2 |
|
* Broadcast: 203.0.113.255
|
||||||
+----+ ^ +----+
|
* R1: 203.0.113.1
|
||||||
203.0.113.0/24
|
* R2: 203.0.113.2
|
||||||
|
* **Unused: 252 addresses**
|
||||||
|
|
||||||
Network address
|
A tiny road, but a massive parking lot sitting empty.
|
||||||
11001011.00000000.01110001.*00000000*
|
|
||||||
203 . 0 . 113 . 0
|
|
||||||
|
|
||||||
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
|
## CIDR (Classless Inter-Domain Routing)
|
||||||
**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 /27
|
* Introduced by the **IETF (Internet Engineering Task Force)** in 1993
|
||||||
**203.0.113.0/27**
|
* Replaced classful addressing
|
||||||
Network address
|
* Removed fixed boundaries:
|
||||||
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*
|
|
||||||
|
|
||||||
#### CIDR /28
|
* Class A = /8
|
||||||
**203.0.113.0/28**
|
* Class B = /16
|
||||||
Network address
|
* Class C = /24
|
||||||
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*
|
|
||||||
|
|
||||||
#### CIDR /29
|
### Why CIDR Matters
|
||||||
*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*
|
|
||||||
|
|
||||||
#### CIDR /30
|
CIDR lets you carve networks like a careful sculptor instead of swinging a sledgehammer.
|
||||||
**203.0.113.0/30**
|
Large networks can be split into smaller, efficient subnets.
|
||||||
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*
|
|
||||||
|
|
||||||
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)
|
## Subnetting Example
|
||||||
are now available to be used in other subnets!
|
|
||||||
|
|
||||||
#### CIDR /31
|
Base network: **203.0.113.0/24**
|
||||||
*203.0.113.0/31*
|
|
||||||
|
|
||||||
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
|
```cisco
|
||||||
Router(config-if)# ip address 203.0.113.0 255.255.255.254
|
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
|
* Hosts: 2⁰ − 2 = −1 (conceptually)
|
||||||
*203.0.113.0/32*
|
|
||||||
|
|
||||||
2^1 -2= -1 usable addresses
|
Used for:
|
||||||
|
|
||||||
can be used in static routes
|
* Loopbacks
|
||||||
don't worry about them now
|
* Static routes
|
||||||
|
* Identifying a single host
|
||||||
|
|
||||||
## Review
|
---
|
||||||
|
|
||||||
- [[CIDR]] (Classless Inter-Domain Routing)
|
## Key Takeaways
|
||||||
- The process of subnetting
|
|
||||||
|
|
||||||
|
* CIDR enables flexible and efficient IP allocation
|
||||||
|
* Subnetting reduces waste and improves scalability
|
||||||
|
* Smaller subnets = better utilization of address space
|
||||||
|
|||||||
Reference in New Issue
Block a user