Subnetting is the process of dividing a large IP network into smaller subnetworks to reduce broadcast domains, simplify management, and improve performance and security.
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128
2^8 = 256
2^9 = 512
2^10 = 1024
| Subnet Mask | CIDR |
|---|---|
| 255.255.255.128 | /25 |
| 255.255.255.192 | /26 |
| 255.255.255.224 | /27 |
| 255.255.255.240 | /28 |
| 255.255.255.248 | /29 |
| 255.255.255.252 | /30 |
Block size = 256 - subnet mask
Subnets = 2^x (x = number of 1 bits)
Hosts per subnet = 2^y - 2 (y = number of 0 bits)
Subnets: 2
Hosts per subnet: 126
Valid subnets: 0 and 128
Broadcast addresses: 127 and 255
Host ranges:
Subnet 0: 192.168.10.1 to 192.168.10.126
Subnet 128: 192.168.10.129 to 192.168.10.254
ping 127.0.0.1 → test TCP/IP stack
ping local IP → test network card
ping default gateway → test LAN connection
ping remote server → test WAN or DNS routing
Error: Gateway address is set as broadcast address
Fix: Use a valid host IP from the subnet
Error: Host IP equals broadcast address
Fix: Pick an address between network and broadcast
Network: 192.168.20.24/29
Mask: 255.255.255.248
Router: 192.168.20.25
Server: 192.168.20.30
Gateway: 192.168.20.25
Network Address Translation maps private IPs to public IPs, allowing secure internet access and IPv4 address conservation.
| Pros | Cons |
|---|---|
| Preserves public IPs | Harder to trace hosts |
| Provides flexibility | Some apps may fail with NAT |
| Improves security | Adds translation latency |
10.1.1.1:5000 → 203.0.113.1:5000
10.1.1.2:6000 → 203.0.113.1:6000
Response packets are mapped back via NAT table
203.0.113.1:80 → 192.168.1.10:80 (Internal Web Server)