DevOps Hub/Next.js 16.3 · Docker · Port 3008
All systems operational
Track 1 of 523 Interactive Modules

SubnetLab & Networking Infrastructure

Comprehensive interactive guide covering fundamental IP addressing, binary operations, CIDR, VLSM, VLANs, routing protocols, packet inspection, wireless networks, and network security.

Interactive Subnetting & Network Architecture Guide

Mastering Subnets

From binary bitwise operations and CIDR calculations to VLSM, VLAN isolation, cloud VPC design, and firewall rules — master IP networking through interactive visualisations and real-time drills.

IPv4 & IPv6Bitwise ANDVLSM TreeAWS / Azure VPCDrill GeneratorWireshark PCAP
Start Learning
#basics

1. What is a Subnet?

A Subnet (Subnetwork) is a logical subdivision of an IP network. By partitioning a large network into smaller, isolated sub-networks, organization network administrators minimize broadcast noise, enhance security isolation, and optimize Layer 3 routing efficiency across local and cloud environments.

Performance & Traffic Control

Subnetting constrains Layer 2 broadcast domains. Without subnets, broadcast frames (ARP, DHCP) flood every host on the switch, causing broadcast storms and high network latency.

Broadcast ScopeLocal Only
🛡️

Enhanced Security Isolation

Enforces Zero-Trust boundary controls between host groups. Isolates sensitive infrastructure (Database, Payment Gateways, Admin) from public-facing web servers and Guest Wi-Fi.

Access ControlL3 ACL / Firewall
📐

Logical Addressing & Scale

Enables structured IP Address Management (IPAM). Facilitates route summarization, simplified troubleshooting, and scalable allocation across physical buildings or cloud Availability Zones.

IP ArchitectureStructured Hierarchy

Network Topology Example: 192.168.1.0/24 Subnet Partitioning

A single Class C block divided into 3 distinct functional subnets with a central Layer 3 Gateway Router.

Total IPs: 256
Core Gateway Router
192.168.1.1 / 24
Inter-Subnet Layer 3 Routing & NAT
Subnet AVLAN 10

Management & Admin

192.168.1.0 / 26
Mask:255.255.255.192
Usable IPs:.1 — .62 (62 hosts)
Gateway:192.168.1.1
Admin Workstation (192.168.1.10)
Core Switch Mgmt (192.168.1.2)
NAS Backup Vault (192.168.1.15)
Subnet BVLAN 20

Staff Workstations

192.168.1.64 / 26
Mask:255.255.255.192
Usable IPs:.65 — .126 (62 hosts)
Gateway:192.168.1.65
Office PC-01 (192.168.1.70)
Dev Laptop-04 (192.168.1.85)
VoIP Desk Phone (192.168.1.90)
Subnet CVLAN 30

IoT & Guest Wi-Fi

192.168.1.128 / 25
Mask:255.255.255.128
Usable IPs:.129 — .254 (126 hosts)
Gateway:192.168.1.129
Smart TV (192.168.1.135)
Guest Phone (192.168.1.142)
IP Security Camera (192.168.1.200)
#binary

2. IP Addresses & Binary

Every IPv4 address is a 32-bit binary number represented in 4 decimal octets separated by dots. Understanding bit values, positional binary weights ($128, 64, 32, 16, 8, 4, 2, 1$), and bitwise operations is fundamental to networking.

Live 4-Octet Decimal to Binary Converter

Enter values from 0 to 255 for each octet to visualize their 8-bit binary representation in real time.

192.168.1.100
Octet 1: 192
128
1
64
1
32
0
16
0
8
0
4
0
2
0
1
0
Octet 2: 168
128
1
64
0
32
1
16
0
8
1
4
0
2
0
1
0
Octet 3: 1
128
0
64
0
32
0
16
0
8
0
4
0
2
0
1
1
Octet 4: 100
128
0
64
1
32
1
16
0
8
0
4
1
2
0
1
0
Full 32-Bit Binary Representation:11000000 . 10101000 . 00000001 . 01100100

IPv4 Address Anatomy: Network ID vs Host ID

Every IP address is divided into two logical sections by its subnet mask: the Network Portion (Prefix) which identifies the specific network, and the Host Portion (Suffix) which identifies the unique device interface on that network.

Bit 1← Network Prefix Bits (1s in Mask) →← Host Suffix Bits (0s in Mask) →Bit 32
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
24 Network Bits (e.g. /24 Subnet)8 Host Bits ($2^8 - 2 = 254$ Hosts)

RFC 1918 Private IP Address Ranges

RFC 1918 designates three IP address ranges reserved exclusively for private internal networks. These IPs are non-routable on the public internet.

ClassCIDR BlockIP Address RangeTotal AddressesTypical Application
Class A10.0.0.0 / 810.0.0.0 — 10.255.255.25516,777,216Enterprise corporate networks, cloud VPCs
Class B172.16.0.0 / 12172.16.0.0 — 172.31.255.2551,048,576Medium corporate LANs, Docker internal bridges
Class C192.168.0.0 / 16192.168.0.0 — 192.168.255.25565,536Home routers, SOHO local networks, Wi-Fi hotspots

Classful vs CIDR Addressing

Historical Classful routing forced rigid network boundaries, leading to rapid IP address exhaustion. CIDR (Classless Inter-Domain Routing) introduced variable-length prefix masks.

FeatureLegacy Classful (RFC 791)Modern CIDR (RFC 1519)
Mask AllocationFixed octet boundaries (/8, /16, /24)Arbitrary bit boundaries (/1 to /32)
Routing Protocol SupportRIPv1, IGRP (No subnet mask sent in updates)OSPF, BGP4, RIPv2, IS-IS (Subnet mask explicitly sent)
IP Utilization EfficiencyVery Poor (Extreme address wastage)High (Optimal subnet sizing via VLSM)
Route Table AggregationImpossible (Unaggregated full routing tables)Supernetting & BGP Prefix Aggregation enabled
127.0.0.0 / 8

Loopback Address Space

Reserved for host-internal network stack testing (127.0.0.1 / localhost). Traffic sent to loopback never hits physical network interfaces or switch ports.

ping 127.0.0.1 → Tests local TCP/IP protocol stack functionality
169.254.0.0 / 16

APIPA (Link-Local)

Automatic Private IP Addressing (RFC 3927). Self-assigned by operating systems when a DHCP server fails to respond. Non-routable across routers.

IP range: 169.254.0.1 — 169.254.255.254 (Used for direct peer connection)

Bitwise AND Operation: Calculating Network Address

When a router evaluates an incoming packet, it performs a bitwise AND operation between the Destination IP Address and the Subnet Mask to determine the target Network Address.

Host IP (192.168.1.100):11000000 . 10101000 . 00000001 . 01100100
Subnet Mask (255.255.255.0):11111111 . 11111111 . 11111111 . 00000000
AND OPERATOR (1 AND 1 = 1, ALL OTHER COMBINATIONS = 0)
Network ID (192.168.1.0):11000000 . 10101000 . 00000001 . 00000000
#cidr

3. CIDR & Subnet Masks — Interactive

CIDR (Classless Inter-Domain Routing) specifies how many leading bits in an IP address represent the network prefix. Adjust the slider or click any bit box below to interactively observe how changing prefix length affects subnet mask, bit allocation, total addresses, and usable host count.

Subnet Mask Bit Allocator

Selected Prefix: /24 (24 Network Bits, 8 Host Bits)

/1 (Half the Internet)/24 Prefix/30 (2 Usable Hosts)
24 Blue Network Bits (1)8 Green Host Bits (0) →
Octet 1255
Octet 2255
Octet 3255
Octet 40
Subnet Mask
255.255.255.0
Equivalent to /24 CIDR prefix
Total IP Addresses
256
$2^{32 - 24} = 2^{ 8 }$
Usable Host IPs
254
Excludes Network & Broadcast
Wildcard Mask (ACL)
0.0.0.255
Inverted subnet mask ($255 - \text{Mask}$)

Usable Hosts Calculation Formula: $2^h - 2$

To calculate the number of hosts that can be assigned to devices on a IPv4 subnet, use the formula Usable Hosts = 2^h - 2, where h = 32 - CIDR is the number of remaining host bits.

Why subtract 2 addresses?
1. Network Address (All Host Bits = 0)The first IP address in the range identifies the subnet block itself in routing tables and cannot be assigned to an interface.
2. Broadcast Address (All Host Bits = 1)The last IP address in the range is used to broadcast frames to all active devices on the subnet simultaneously.
Step-by-Step for /24:
1. Host bits $h = 32 - 24 = \mathbf{ 8 }$
2. Total addresses $2^{ 8 } = \mathbf{ 256 }$
3. Subtract Network & Broadcast:
256 - 2 = 254 Usable Hosts
#vlsm

4. VLSM — Variable Length Subnet Masking

Variable Length Subnet Masking (VLSM) allows network engineers to subdivide an IP address space into non-uniform subnets tailored to exact host requirements. Instead of assigning a fixed mask (like `/24`) everywhere, VLSM prevents IP address exhaustion by assigning larger masks (e.g., `/26`, `/27`, `/30`) where fewer hosts reside.

/30 Prefix255.255.255.252

Point-to-Point Router Links

Provides exactly 4 total IP addresses ($2^2$), yielding 2 usable hosts. Ideal for point-to-point links between two core routers, eliminating address wastage.

Usable Efficiency:50% (2 of 4)
/27 Prefix255.255.255.224

Branch & Small Departments

Provides 32 total IP addresses ($2^5$), yielding 30 usable hosts. Perfect for small department teams, remote office locations, or server racks.

Usable Efficiency:93.75% (30 of 32)
/24 Prefix255.255.255.0

Standard Building / LAN

Provides 256 total IP addresses ($2^8$), yielding 254 usable hosts. Standard default allocation size for corporate office floors and DHCP user pools.

Usable Efficiency:99.2% (254 of 256)

Worked VLSM Example: Subnetting a 192.168.1.0/24 Block

Requirement: Allocate subnets for Engineering (50 hosts), Sales (25 hosts), Executive (10 hosts), and 2 Router Links.

Rule: Always allocate largest requirements first!
DepartmentNeeded HostsAllocated CIDRSubnet MaskNetwork AddressUsable Host RangeBroadcast Address
Engineering50 hosts/26 (64 IPs)255.255.255.192192.168.1.0192.168.1.1 — 192.168.1.62192.168.1.63
Sales25 hosts/27 (32 IPs)255.255.255.224192.168.1.64192.168.1.65 — 192.168.1.94192.168.1.95
Executive10 hosts/28 (16 IPs)255.255.255.240192.168.1.96192.168.1.97 — 192.168.1.110192.168.1.111
Router Link 12 hosts/30 (4 IPs)255.255.255.252192.168.1.112192.168.1.113 — 192.168.1.114192.168.1.115
Router Link 22 hosts/30 (4 IPs)255.255.255.252192.168.1.116192.168.1.117 — 192.168.1.118192.168.1.119
Unassigned PoolFuture expansion136 IPs freeVarious192.168.1.120192.168.1.120 — 192.168.1.255192.168.1.255
Address Space Allocation Tree (192.168.1.0/24)
192.168.1.0/24 (256 Total IPs)
├── 192.168.1.0/26   [Engineering: 50 hosts required, 62 usable (.1-.62)]
├── 192.168.1.64/27  [Sales:       25 hosts required, 30 usable (.65-.94)]
├── 192.168.1.96/28  [Executive:   10 hosts required, 14 usable (.97-.110)]
├── 192.168.1.112/30 [Router Link 1: 2 hosts required, 2 usable (.113-.114)]
├── 192.168.1.116/30 [Router Link 2: 2 hosts required, 2 usable (.117-.118)]
└── 192.168.1.120/24 [Reserved Future Allocation Pool: 136 IPs remaining]
RFC 3021 Standard

/31 Subnet Prefixes on Point-to-Point Links

Under standard IPv4 rules, a /30 subnet uses 4 addresses to supply only 2 usable host IPs (a 50% loss due to dedicated network and broadcast IPs). RFC 3021 eliminates this waste by allowing /31 prefix masks on point-to-point links.

Standard /30 Link (4 IPs):
.0 (Network ID - Unusable)
.1 (Router A Interface)
.2 (Router B Interface)
.3 (Broadcast - Unusable)
RFC 3021 /31 Link (2 IPs - 100% Efficient):
.0 (Router A Interface)
.1 (Router B Interface)
No broadcast or network ID overhead required!
#vlans

5. VLANs & Subnets — How They Connect

While both VLANs (Virtual LANs) and Subnets isolate network traffic, they operate at different layers of the OSI model. Understanding how Layer 2 physical switch isolation pairs with Layer 3 IP addressing is essential for modern enterprise network design.

OSI Layer 2 (Data Link)IEEE 802.1Q

VLAN (Virtual Local Area Network)

Partitioning at the physical switch level. Inserts a 4-byte 802.1Q tag into Ethernet frame headers to divide a single switch into multiple virtual broadcast domains.

Hardware Scope:Ethernet Switches & Trunks
Identifier:VLAN ID (1 — 4094)
Isolation Layer:MAC / Frame Broadcast Scope
OSI Layer 3 (Network)IPv4 / IPv6

IP Subnet (Subnetwork)

Logical IP address grouping defined by subnet masks (e.g., 255.255.255.0). Determines whether a packet stays local or must be routed through a gateway.

Hardware Scope:Routers & L3 Switches
Identifier:Network IP & CIDR Prefix
Isolation Layer:IP Packet Routing Boundaries

Industry Standard: 1:1 Mapping & Inter-VLAN Routing

Best practice dictates mapping exactly one IP Subnet to one VLAN. Communication between VLANs requires a Layer 3 Router or L3 Switch.

802.1Q Trunking
Layer 3 Gateway (Router / L3 Switch)
Inter-VLAN Routing ("Router-on-a-Stick")
Evaluates Firewall ACLs before forwarding packets between subnets
VLAN 10Layer 2
Finance Dept
Subnet: 10.10.10.0 / 24
Gateway: 10.10.10.1
Switch Ports: FastEthernet 0/1 - 0/10
VLAN 20Layer 2
Engineering
Subnet: 10.10.20.0 / 24
Gateway: 10.10.20.1
Switch Ports: FastEthernet 0/11 - 0/20
VLAN 30Layer 2
Guest Wi-Fi
Subnet: 10.10.30.0 / 24
Gateway: 10.10.30.1
Switch Ports: Wireless AP Trunk

Access Ports (End Devices)

Switch ports configured as Access Ports belong to a single native VLAN. They send and receive standard untagged Ethernet frames directly to workstations, printers, and IP phones.

Trunk Ports (IEEE 802.1Q Inter-Switch Links)

Switch ports configured as Trunk Ports multiplex traffic from multiple VLANs over a single physical link by appending a 4-byte 802.1Q VLAN ID tag to each Ethernet frame header.

#ipv6

6. IPv6 — The Next Generation

IPv6 replaces IPv4's 32-bit address space with a massive 128-bit address space ($3.4 \times 10^38$ total addresses). Designed to eliminate NAT workarounds, IPv6 provides end-to-end global connectivity, built-in IPsec security, stateless auto-configuration (SLAAC), and simplified router headers.

IPv6 Address Anatomy: 8 Hextets (128 Bits)

Written as 8 groups of 4 hexadecimal digits (called hextets), separated by colons. Each hextet represents 16 bits ($8 \times 16 = 128$ bits).

Hextet 1
2001
16 bits
Hextet 2
0db8
16 bits
Hextet 3
85a3
16 bits
Hextet 4
0000
16 bits
Hextet 5
0000
16 bits
Hextet 6
8a2e
16 bits
Hextet 7
0370
16 bits
Hextet 8
7334
16 bits
← First 64 Bits: Network / Subnet Prefix →← Last 64 Bits: Interface ID (Host) →

Zero Compression Rules

To make long IPv6 addresses human-readable, RFC 5952 establishes two mandatory compression rules.

Step 1: Original Uncompressed IPv6 Address
2001:0db8:0000:0000:0000:0000:1428:57ab
Rule 1: Omit Leading Zeros

In any hextet, leading zeros can be dropped. For example, 0db8 becomes db8, and 0000 becomes 0.

Rule 2: Double Colon (::) Compression

A single contiguous sequence of all-zero hextets can be replaced with ::.Critical Constraint: :: can only be used ONCE per address to prevent ambiguity when parsing.

IPv4 vs IPv6 Feature Matrix

Architectural comparison between legacy IPv4 protocols and modern IPv6 standards.

FeatureIPv4 StandardIPv6 Standard
Address Size32 Bits (4 Bytes)128 Bits (16 Bytes)
Total Address Count~4.3 Billion ($4.3 \times 10^9$)~340 Undecillion ($3.4 \times 10^38$)
Format NotationDotted Decimal (e.g. 192.168.1.1)Hexadecimal Colons (e.g. 2001:db8::1)
Standard Subnet MaskVariable Prefixes (/8 to /32)Standard /64 Interface Prefix
Address Auto-ConfigurationStateful DHCP requiredStateless SLAAC & Stateful DHCPv6
NAT RequirementMandatory (address space exhaustion)Obsolete (Every host receives public IP)
/64 Standard Subnet

The Universal IPv6 /64 Subnet Prefix

Unlike IPv4 where subnets vary in size, the standard subnet size in IPv6 is almost universally /64. This leaves 64 bits for the Interface ID, allowing SLAAC (Stateless Address Autoconfiguration) to automatically generate unique host addresses.

IPv6 /64 Subnet Structure:Total Host Addresses per /64 = 18.4 Quintillion ($2^64$)
Global Routing Prefix (48 Bits)
Assigned by ISP / RIR
2001:0db8:85a3
Subnet ID (16 Bits)
Internal Subnet Allocation
:0001:
Interface ID (64 Bits)
Host Address (SLAAC / EUI-64)
:0000:0000:0000:0001
#ips

7. Public vs Private IPs & NAT

IP addresses are split into globally routable Public IPs and localized Private IPs. Because IPv4 addresses are scarce, Network Address Translation (NAT) allows hundreds of devices on a private LAN to share a single public IP address when communicating over the internet.

Public IP AddressesGlobally Routable

Internet-Facing Infrastructure

Globally unique addresses assigned by ICANN/IANA through Regional Internet Registries (ARIN, RIPE, APNIC) and ISPs. Directly accessible over the public internet.

Routability:Global Public Internet
Uniqueness:Worldwide Unique
Examples:8.8.8.8 (Google), 1.1.1.1 (Cloudflare)
Private IP AddressesRFC 1918 Local LAN

Internal LAN & Cloud VPCs

Reserved for internal use inside homes, offices, and cloud VPC networks. ISP routers automatically drop private IP packets attempting to cross the public internet.

Routability:Non-Routable on Internet
Uniqueness:Local Network Only
Examples:192.168.1.1, 10.0.0.1, 172.16.0.1

Interactive NAT / PAT (Port Address Translation) Flow

Step-by-step walkthrough showing how a NAT Gateway translates private sockets to public sockets.

Step 1 of 4

Outbound Request Sent by Private Host

Client (192.168.1.50) sends a packet to Web Server (93.184.216.34:80) via ephemeral port 51234.

Private LAN Client
192.168.1.50
Private Network (RFC 1918)
NAT Gateway Router
LAN: 192.168.1.1
WAN Public: 203.0.113.5
Rewrites Packet Headers
Public Web Server
93.184.216.34:80
Global Public Internet
Active Packet Header State:
Source Socket:192.168.1.50 : 51234
Destination Socket:93.184.216.34 : 80
Router NAT Translation Table:
Private SocketPublic NAT Socket
Creating translation state...
#calculator

8. Subnet Calculator

Enter an IPv4 address and select a CIDR prefix length to calculate network boundaries, broadcast addresses, usable host ranges, and subnet masks in real time.

Network Address
192.168.1.0/24
Subnet identifier (All host bits = 0)
Broadcast Address
192.168.1.255
Subnet broadcast target (All host bits = 1)
First Usable Host
192.168.1.1
First assignable host IP in range
Last Usable Host
192.168.1.254
Last assignable host IP in range
Subnet Mask
255.255.255.0
Subnet mask in dotted-decimal format
Usable Hosts
254
Total assignable host IP addresses

Common Subnet Quick Reference

CIDRSubnet MaskUsable HostsTypical Use
/16255.255.0.065,534Large Enterprise / Cloud VPC
/24255.255.255.0254Standard Local Subnet (LAN / Office)
/25255.255.255.128126Medium Department (100+ devices)
/26255.255.255.19262Small Department / Server Rack
/27255.255.255.22430Branch Office / Small Workgroup
/28255.255.255.24014Management Network / DMZ Subnet
/30255.255.255.2522Point-to-Point Router Link
#create

9. Creating Subnets on Your Local Network

Building custom subnets on a local area network requires methodical planning and accurate configuration across your gateway router, managed switches, and endpoint operating systems. Follow this 4-step workflow to partition and verify your subnets.

01Architecture & Sizing

Step 1: Plan Address Space & CIDR Blocks

Select a private RFC 1918 base network (e.g. 192.168.0.0/16) and divide it into subnets based on required host capacity and isolation goals.

VLAN 10 (Staff):192.168.10.0/24 (254 hosts)
VLAN 20 (Guest):192.168.20.0/24 (254 hosts)
VLAN 30 (Servers):192.168.30.0/28 (14 hosts)
💡 Always reserve .0 (Network), .1 (Default Gateway), and .255 (Broadcast).
02Cisco IOS / Switch Config

Step 2: Configure Router/Switch Gateways

Configure 802.1Q sub-interfaces on your router (Router-on-a-Stick) or SVIs on a Layer 3 switch to act as default gateways.

! Step 2: Configure Router Sub-Interfaces (Router-on-a-Stick)
interface GigabitEthernet0/0.10
 description LAN_Subnet_Staff
 encapsulation dot1Q 10
 ip address 192.168.10.1 255.255.255.0
 no shutdown
!
interface GigabitEthernet0/0.20
 description LAN_Subnet_Guest
 encapsulation dot1Q 20
 ip address 192.168.20.1 255.255.255.0
 no shutdown
03

Step 3: Assign IP Addresses to Host Interfaces

Configure static IP address parameters, netmasks, and default gateways directly on host machines via OS CLI tools.

# Assign Static IP & Netmask on Windows via Netsh
netsh interface ip set address name="Ethernet" static 192.168.10.50 255.255.255.0 192.168.10.1

# Configure Primary DNS Server
netsh interface ip set dns name="Ethernet" static 1.1.1.1
04ICMP & Diagnostics

Step 4: Verify & Test Inter-Subnet Routing

Confirm local gateway reachability, test cross-subnet packet forwarding, and inspect hop pathways using standard diagnostic utilities.

# 1. Verify Gateway Reachability
ping 192.168.10.1

# 2. Test Inter-Subnet Routing to Guest Subnet
ping 192.168.20.50

# 3. Trace Route Path across Gateway (Windows / Linux)
tracert 192.168.20.50   # Windows
traceroute 192.168.20.50 # Linux / macOS
#supernetting

10. Supernetting & CIDR Aggregation

Supernetting (also called CIDR Route Aggregation or Route Summarization) is the process of combining multiple contiguous smaller networks into a single, shorter-prefix network route. This dramatically reduces core routing table sizes and conserves memory on enterprise network backbones.

Before Aggregation (4 Individual Routes)

Bloated Routing Table

Routers must store, query, and advertise four separate routing table entries for adjacent subnets:

S 192.168.0.0/24via 10.1.1.1
S 192.168.1.0/24via 10.1.1.1
S 192.168.2.0/24via 10.1.1.1
S 192.168.3.0/24via 10.1.1.1

After Aggregation (1 Supernet Route)

75% Table Reduction

All 4 subnets are consolidated into a single summary prefix with a shorter network mask:

S 192.168.0.0/22via 10.1.1.1
Covers range: 192.168.0.0 to 192.168.3.255 (Total 1,024 IP addresses in 1 route entry).
#cloud

11. Subnets in the Cloud

Cloud hyperscalers (AWS, Azure, GCP) use Software-Defined Networking (SDN) to deliver virtual private clouds. While cloud subnets share traditional CIDR math, cloud vendors enforce vendor-specific IP reservations, availability zone scopes, and routing rules.

AWS VPC (Virtual Private Cloud)

Cloud SDN Subnet Architecture
Subnet Scope & Availability

Subnets are strictly bound to a single Availability Zone (AZ).

Reserved Addresses

5 Reserved IPs per subnet (.0 network, .1 VPC router, .2 AWS DNS, .3 reserved, .255 broadcast).

Infrastructure-as-Code Configuration (Terraform)
# AWS VPC & Subnet Terraform Example
resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "public_az1" {
  vpc_id            = aws_vpc.main.id
  cidr_block        = "10.0.1.0/24"
  availability_zone = "us-east-1a"
}

📋 Cloud Subnetting Architecture Checklist & Tips

Plan for Future Scale & Non-overlapping Address Space

Always select large VPC CIDR blocks (/16) even when starting small. Never overlap VPC ranges with on-premise IP networks (10.x.x.x or 172.16.x.x) to enable seamless VPN/DirectConnect hybrid routing.

Enforce Strict Public vs. Private Subnet Separation

Place internet-facing load balancers in Public Subnets (attached to Internet Gateways) and application/database workloads in Private Subnets (routed via NAT Gateways for outbound access only).

Account for Cloud IP Reservations in Sizing Calculations

Remember AWS and Azure reserve 5 IP addresses per subnet (.0, .1, .2, .3, .255). A small /29 subnet provides only 3 usable host IPs instead of 6.

Deploy Multi-AZ Redundancy Across Availability Zones

Provision identical subnets across at least 2 or 3 Availability Zones (e.g. us-east-1a, us-east-1b) to ensure multi-AZ fault tolerance for enterprise workloads.

Isolate High-Security Subnets with Network ACLs (NACLs)

Combine Cloud Security Groups (stateful) with Network ACLs (stateless at the subnet boundary) to enforce explicit packet filtering between database and web subnets.

#firewall

12. Firewall Rules Between Subnets

Subnetting divides physical networks into isolated broadcast domains, but routers forward traffic between subnets by default. Firewalls & Access Control Lists (ACLs) enforce Zero-Trust boundaries by inspecting and filtering packet headers at subnet gateways.

🚫

Default-DENY (Block)

Enforces Zero-Trust isolation. Inter-subnet traffic is implicitly or explicitly dropped unless an explicit permit rule allows it.

Action: DROP / REJECTDefault Guard

Granular PERMIT (Allow)

Allows specific protocol, source CIDR, destination CIDR, and port combinations (e.g. Web Subnet to DB Subnet on TCP 5432).

Action: ACCEPTPort Specific
📊

Stateful Audit & LOG

Captures dropped connection attempts, port scans, and unauthorized inter-subnet packets to SIEM monitoring tools for incident analysis.

Action: AUDIT / SIEMTraffic Analytics

Cisco IOS Inter-Subnet Access Control List (ACL 100)

Extended ACL Logic

Extended ACLs filter based on source/destination IPs and TCP/UDP ports. Apply inbound on the router sub-interface closest to the source:

! Cisco Extended Access Control List (ACL 100)
! 1. Allow Web Subnet (VLAN 10) to access Database Subnet (VLAN 20) on PostgreSQL port 5432
access-list 100 remark --- Permit Web to DB Postgres ---
access-list 100 permit tcp 192.168.10.0 0.0.0.255 192.168.20.0 0.0.0.255 eq 5432

! 2. Allow Web Subnet (VLAN 10) to access Shared HTTPS Services (VLAN 30)
access-list 100 remark --- Permit Web to Shared HTTPS ---
access-list 100 permit tcp 192.168.10.0 0.0.0.255 192.168.30.0 0.0.0.255 eq 443

! 3. Explicitly DENY all remaining inter-subnet traffic & log violation attempts
access-list 100 remark --- Deny & Log all other cross-subnet packets ---
access-list 100 deny ip 192.168.10.0 0.0.0.255 192.168.20.0 0.0.0.255 log

! 4. Apply ACL inbound on VLAN 10 Interface
interface GigabitEthernet0/0.10
 ip access-group 100 in

🛡️ Home & Small Network Firewall Rule Best Practices

Isolate Guest Wi-Fi Subnet Completely

Enable 'Guest Network Isolation' on your Wi-Fi router so guests (e.g. 192.168.2.0/24) cannot scan or connect to private NAS drives, PCs, or printers on 192.168.1.0/24.

Segregate Smart Home IoT Devices into a Dedicated VLAN

Place smart TVs, cameras, smart plugs, and voice assistants on an isolated IoT subnet (e.g. 192.168.50.0/24). Block inbound requests from the IoT subnet to your main LAN.

Disable UPnP Across Inter-Subnet Boundaries

Universal Plug and Play (UPnP) should be strictly disabled between subnets to prevent malicious IoT software from dynamically requesting open router port forwards.

Utilize Stateful Firewall Engines (pfSense / OPNsense / UniFi)

Deploy stateful firewall rules that automatically permit return traffic for outbound requests initiated by trusted LAN hosts without opening static inbound ports.

#troubleshooting

13. Troubleshooting Subnet Issues

Subnetting issues can lead to subtle network failures, including host isolation, asymmetric routing, IP conflicts, and cross-subnet packet drops. Master these 6 diagnostic scenarios and follow the 6-step troubleshooting workflow.

6 Common Subnet Misconfigurations & Solutions

1. Misconfigured Subnet Mask (Off-by-One CIDR)

Mask Mismatch
⚠️ Symptom / Impact

Host A (192.168.1.50/24) cannot reach Host B (192.168.1.200/25). Host B incorrectly treats Host A as external and sends packets to Gateway.

💡 Resolution Strategy

Verify netmask uniformity across all hosts in the subnet block.

Diagnostic CLI Commands
# Windows: Inspect IPv4 Subnet Mask
ipconfig /all

# Linux: Verify assigned IP & Prefix length
ip -4 addr show dev eth0

🩺 6-Step Subnet Diagnostic Workflow

Step 1ipconfig /all | ip addr

Verify Local IP Address & Subnet Mask

Ensure host has a valid IP address (not 0.0.0.0 or APIPA 169.254.x.x) and correct netmask matching network plan.

Step 2ping 127.0.0.1

Test Local Loopback & Interface

Ping 127.0.0.1 and local host IP to verify local TCP/IP protocol stack and NIC driver functionality.

Step 3ping 192.168.10.1

Ping Default Gateway IP

Test ICMP reachability to local subnet router interface (e.g. 192.168.10.1) to confirm Layer 2 switch connectivity.

Step 4tracert 192.168.20.50

Trace Route Path to Target Destination

Execute traceroute to locate exact router hop where inter-subnet packet forwarding fails or times out.

Step 5nslookup domain.com | nc -zv IP PORT

Test DNS & Targeted TCP/UDP Ports

Verify whether issue is pure IP layer routing or higher-layer DNS resolution / firewall port blocking.

Step 6show vlan brief | show access-lists

Audit Switch VLANs & Firewall ACL Rules

Check switchport VLAN assignments, 802.1Q trunk tags, stateful firewall rules, and router ACL drop counters.

#practice

14. Practice Problems

Master subnetting with real-world scenarios and certification-style drill questions. Test your calculations for network boundaries, host ranges, broadcast addresses, and VLSM allocations, then toggle answers to verify your steps.

Easy172.16.5.0/24

Problem 1: Basic Subnetting

You are given the network address 172.16.5.0/24. Calculate the Network ID, Subnet Mask, First Usable Host IP, Last Usable Host IP, Broadcast Address, and Total Usable Hosts.

Medium10.1.1.0/24 into 4 Subnets

Problem 2: Subnet Division

Divide the network 10.1.1.0/24 into 4 equal subnets. Determine the new CIDR prefix length, Subnet Mask, Block Size, and list each created subnet with its Network ID, Usable Range, and Broadcast Address.

Medium192.168.10.150/27

Problem 3: Find the Network

An engineer discovers a workstation configured with IP address 192.168.10.150/27. Determine the Network ID, Subnet Mask, First & Last Usable Host IPs, and Broadcast Address for the subnet block it belongs to. Is 192.168.10.150 a valid host address?

Hard192.168.1.0/24 (WAN, Mkt, Fin)

Problem 4: VLSM Challenge

Given the single base network block 192.168.1.0/24, design a Variable Length Subnet Masking (VLSM) allocation for three subnets: Finance (25 hosts needed), Marketing (12 hosts needed), and WAN Link (2 hosts needed). Order from largest to smallest requirement to avoid address overlap.

Real-World10.0.5.100/28 vs 10.0.5.113

Problem 5: Real-World Scenario

A database server is assigned IP 10.0.5.100/28. A system administrator attempts to ping a default gateway at 10.0.5.113. Will this ping succeed directly on the local Layer 2 broadcast domain without passing through a router? Determine the exact subnet boundary for 10.0.5.100/28.

#cheatsheet

15. Subnetting Cheat Sheet

Quick-reference hub containing essential subnet formulas, comprehensive CIDR prefix lookup tables (/8 through /32), and mental math shortcuts for rapid network calculations in exams and production deployments.

📐Core Subnetting Formulas

Total IP Addresses

2^(32 - CIDR) = 2^H

Calculates total raw IP addresses in block including network & broadcast.

Ex: For /24: 32 - 24 = 8 host bits => 2^8 = 256 IPs

Usable Host Count

2^H - 2

Subtracts 2 for Network ID (first address) and Broadcast ID (last address).

Ex: For /24: 256 - 2 = 254 usable host addresses

Block Size (Magic Number)

256 - Mask Octet OR 2^H (in target octet)

Determines the exact step size between adjacent network boundaries.

Ex: Mask 255.255.255.224 => 256 - 224 = 32 increment step

Wildcard Mask (Inverse)

255.255.255.255 - Subnet Mask

Used in Cisco Access Control Lists (ACLs) and OSPF network commands.

Ex: 255.255.255.255 - 255.255.255.240 = 0.0.0.15

Network Address

IP Address AND Subnet Mask

Performs bitwise AND matching between IP address and subnet mask.

Ex: 192.168.10.150 AND 255.255.255.224 = 192.168.10.128

Broadcast Address

Network Address + (Block Size - 1)

Last address in the subnet block where all host bits equal binary 1.

Ex: 192.168.10.128 + (32 - 1) = 192.168.10.159

First Usable Host

Network Address + 1

First assignable IP address for network interfaces/endpoints.

Ex: 192.168.10.128 + 1 = 192.168.10.129

Last Usable Host

Broadcast Address - 1

Final assignable IP address before the broadcast boundary.

Ex: 192.168.10.159 - 1 = 192.168.10.158

Subnets Created

2^(Borrowed Bits)

Calculates total equal subnets created when extending network prefix.

Ex: Borrow 3 bits from /24 => 2^3 = 8 subnets (/27)

📊Prefix Quick Reference Table (/8 to /32)

Complete CIDR lookup listing netmasks, host counts, magic numbers, and practical RFC use-cases.

/31 Prefix NoteRFC 3021

RFC 3021 enables 2 usable IP addresses on point-to-point links with zero overhead (no reserved network or broadcast addresses), doubling IPv4 address efficiency on WAN links compared to traditional /30.

📌
/32 Prefix NoteSingle Host Route

A /32 prefix represents a single host route (255.255.255.255). Used for router loopback interfaces (Router IDs in OSPF/BGP) and explicit single-IP host firewall rules.

CIDRSubnet MaskTotal IPsUsable HostsBlock Size (Increment)Primary RFC / Production Use Case
/8Class A
255.0.0.016,777,21616,777,214256 (Octet 1)Class A Default / Large Global Core Networks
/9
255.128.0.08,388,6088,388,606128 (Octet 2)Telco Backbones & Regional Supernets
/10
255.192.0.04,194,3044,194,30264 (Octet 2)Carrier-Grade NAT (CGNAT 100.64.0.0/10)
/11
255.224.0.02,097,1522,097,15032 (Octet 2)Large Enterprise Data Centers
/12
255.240.0.01,048,5761,048,57416 (Octet 2)Cloud VPC Private Allocations (RFC 1918 172.16.0.0/12)
/13
255.248.0.0524,288524,2868 (Octet 2)Multi-Region Cloud Supernets
/14
255.252.0.0262,144262,1424 (Octet 2)Large Service Provider Blocks
/15
255.254.0.0131,072131,0702 (Octet 2)Regional Metro Networks
/16Class B
255.255.0.065,53665,5341 (Octet 2) / 256 (Octet 3)Class B Default / Standard Cloud VPC (192.168.0.0/16, 10.0.0.0/16)
/17
255.255.128.032,76832,766128 (Octet 3)University & Large Campus LANs
/18
255.255.192.016,38416,38264 (Octet 3)Enterprise Office Hubs
/19
255.255.224.08,1928,19032 (Octet 3)Regional Corporate Buildings
/20
255.255.240.04,0964,09416 (Octet 3)Cloud Availability Zone (AZ) Subnets
/21
255.255.248.02,0482,0468 (Octet 3)Large Office Campus Subnets
/22
255.255.252.01,0241,0224 (Octet 3)Kubernetes Node / Pod CIDR Blocks
/23
255.255.254.05125102 (Octet 3)Medium Branch Office Networks
/24Class C
255.255.255.02562541 (Octet 3) / 256 (Octet 4)Class C Default / Standard Office & Home LAN
/25
255.255.255.128128126128 (Octet 4)Half /24 Subnet / Office Department
/26
255.255.255.192646264 (Octet 4)Standard Corporate Department Subnet
/27Popular
255.255.255.224323032 (Octet 4)Small Team Subnet / Wireless Segment
/28
255.255.255.240161416 (Octet 4)Server Rack / Database Cluster
/29
255.255.255.248868 (Octet 4)Router Cluster / HSRP / VRRP Virtual VIPs
/30Legacy P2P
255.255.255.252424 (Octet 4)Traditional Point-to-Point Router Link (2 Usable / 2 Reserved)
/31RFC 3021
255.255.255.254222 (Octet 4)Point-to-Point Link (RFC 3021 - 0 Network/Broadcast Overhead)
/32Host Route
255.255.255.255111 (Octet 4)Host Route / Loopback Interface / Firewall Rule

🧠Mental Math Tricks Grid (4 Cards)

🪄

1. The Magic 256 Rule

Step Size

Instant Subnet Increment Step

Subtract the non-255 subnet mask octet from 256 to calculate the exact block size (subnet increment) in seconds.

Block Size = 256 - (Interesting Octet Mask)
Example: Mask 255.255.255.224 => 256 - 224 = 32 step size. Subnets: .0, .32, .64, .96, .128, .160, .192, .224.
🖐️

2. Finger-Counting Bit Borrowing

Subnet Doubling

Double Subnets, Halve Host Capacity

Every bit borrowed doubles the created subnets (2^n) and halves host capacity per subnet. Count on fingers from 1 to 6 bits.

1 bit=2 | 2 bits=4 | 3 bits=8 | 4 bits=16 | 5 bits=32 | 6 bits=64
Example: Starting at /24: Borrowing 3 bits yields /27 prefix (2^3 = 8 subnets with 32 IPs each).
🎯

3. Octet Jump Shortcuts

Target Octet

Locate the 'Interesting Octet' Instantly

Quickly map CIDR prefixes to their active working octet without converting binary digits:

/8 to /15 => Octet 2 | /16 to /23 => Octet 3 | /24 to /30 => Octet 4
Example: CIDR /20 falls in Octet 3 (255.255.240.0). Octet 1 & 2 are 255, Octet 4 is 0.

4. Quick Wildcard Mask Inversion

ACL & OSPF

Subtract Subnet Mask from 255.255.255.255

Derive Cisco ACL wildcard masks instantly by subtracting each mask octet from 255.

Wildcard = (255 - Mask Octet) for each of 4 octets
Example: Subnet Mask 255.255.255.240 (/28) => (255-255).(255-255).(255-255).(255-240) = 0.0.0.15.
#quiz

16. Test Your Knowledge

Click an answer to check it. Your score is tracked at the bottom.

Q1How many usable hosts does a /26 subnet have?

Q2What is the broadcast address of 192.168.1.64/26?

Q3Which subnet mask matches /27?

Q4In VLSM, why should you allocate subnets from largest to smallest?

Q5What does NAT stand for?

Q6How many subnets do you get by borrowing 3 bits from a /24?

Q7Which address is NOT valid in 192.168.1.0/30?

Q8What is the primary purpose of a VLAN?

Your Score

0 / 8

Keep practicing! Review the sections above and try again.

#containers

21. Cloud-Native & Container Networking

Modern cloud-native systems rely on virtualized network namespaces (netns), virtual ethernet pairs (veth), overlay tunnels, and kernel-level packet manipulation. Discover how Kubernetes CNI plugins, Docker isolation modes, and Layer 4/7 load balancers route microservice traffic at scale.

1. Kubernetes Networking Architecture & CIDR Ranges

Kubernetes enforces a mandatory IP-per-Pod flat network model: every Pod gets its own routable IP address and can communicate with all other Pods across nodes without NAT.

Pod CIDR Range: 10.244.0.0/16Allocated per Node (/24 per Worker)

Real IP addresses assigned directly to container network interfaces (eth0 inside Pod). Allocated dynamically by the CNI plugin when Pods start up. Pod IPs change every time a Pod is recreated or rescheduled.

Worker Node 1 Subnet
10.244.1.0/24
Pods: 10.244.1.2 - 10.244.1.254
Worker Node 2 Subnet
10.244.2.0/24
Pods: 10.244.2.2 - 10.244.2.254
Worker Node 3 Subnet
10.244.3.0/24
Pods: 10.244.3.2 - 10.244.3.254

🔌 CNI (Container Network Interface) Plugins Comparison

Cilium CNI (eBPF)

Project Maintainer: Isovalent / CNCF
eBPF (Extended Berkeley Packet Filter)
NetworkPolicy Enforcement:L3/L4 + L7 API-Aware (HTTP, gRPC, Kafka)
Performance Profile:Maximum (Direct socket bypass, bypasses iptables/IPVS)

Injects bytecode programs directly into kernel hooks (tc, cgroups, XDP). Replaces iptables DNAT entirely with eBPF BPF_MAP lookup tables. Provides Hubble deep flow observability and transparent WireGuard encryption.

# Cilium L7 HTTP NetworkPolicy Example
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: secure-api-access
spec:
  endpointSelector:
    matchLabels:
      app: payment-service
  ingress:
  - fromEndpoints:
    - matchLabels:
        app: checkout
    toPorts:
    - ports:
      - port: "8080"
        protocol: TCP
      rules:
        http:
        - method: "POST"
          path: "/v1/charge"

2. Docker Networking Drivers & Modes

Docker uses container network drivers to manipulate Linux network namespaces, iptables NAT tables, and virtual interfaces. Select a mode below to analyze host binding, performance, and packet paths.

Bridge Mode (Default)

docker run --net=bridge
Subnet Scope: 172.17.0.0/16 (docker0)

Containers connect to a virtual software bridge (docker0) via virtual ethernet (veth) pairs. Outbound traffic uses IP Masquerading (NAT). User-defined bridges enable automatic container name DNS lookup.

✓ Architectural Advantages
  • Isolated container network namespace
  • Automatic container DNS on custom bridges
  • Secure default for standalone single-host containers
⚠ Technical Limitations
  • Port forwarding NAT overhead
  • Cannot span across multiple physical hosts without custom routing
Docker CLI Execution Example:
docker run -d --name web -p 8080:80 nginx:alpine

3. Layer 4 (L4) vs Layer 7 (L7) Load Balancing & Ingress

Load balancers operate at different OSI layers to distribute traffic across container replicas. Compare transport-level packet routing (L4) with application-level HTTP routing (L7).

🌐 L7 Ingress Controller Mechanics

  • Inspection Depth: Decrypts TLS certificates (HTTPS Termination), parses HTTP methods, URI paths (/v1/users), Host headers (api.domain.com), and cookies.
  • Advanced Traffic Controls: Supports Canary deployment traffic splits (90/10 weighted routing), rate-limiting, CORS injection, and Web Application Firewall (WAF) rule sets.
  • Direct Pod Bypass: Modern K8s Ingress Controllers (NGINX/Envoy) watch K8s Endpoints API directly and forward packets straight to target Pod IPs without ClusterIP NAT overhead.
Kubernetes Ingress Manifest (networking.k8s.io/v1)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: production-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
  ingressClassName: nginx
  rules:
  - host: api.company.com
    http:
      paths:
      - path: /v1/users
        pathType: Prefix
        backend:
          service:
            name: user-service
            port:
              number: 8080
      - path: /v1/orders
        pathType: Prefix
        backend:
          service:
            name: order-service
            port:
              number: 9090

4. Interactive K8s Service IP Routing Simulator

Live Kernel Packet Processing

Test how incoming client packets travel through Kubernetes abstractions (ClusterIP, NodePort, LoadBalancer, Headless, and Ingress) using either legacy iptables or high-performance eBPF data paths!

Backend Pod Target Replicas (Total Requests: 0)
pod-10 Hits (0%)
Pod IP: 10.244.1.14:8080
Worker-1 (192.168.10.101)
pod-20 Hits (0%)
Pod IP: 10.244.2.88:8080
Worker-2 (192.168.10.102)
pod-30 Hits (0%)
Pod IP: 10.244.3.42:8080
Worker-3 (192.168.10.103)
📡 Live Packet Translation TraceEngine: eBPF bpf_sockmap
Click "Send Packet / Trigger Request" above to trace kernel packet routing...
#diagnostics

22. Network Diagnostics & CLI Sandbox

Master essential network troubleshooting CLI utilities (ping, traceroute, mtr, iperf3, dig, nmap). Test commands interactively in the simulated bash terminal sandbox, execute instant command presets, and reference the diagnostic cheat sheet.

guest@net-sandbox: ~ (bash)
========================================================================
NETWORK DIAGNOSTICS & CLI SANDBOX v2.4 (Simulated Bash Kernel)
Supported commands: ping, traceroute, mtr, iperf3, dig, nmap, clear, help
Tip: Type commands directly or click preset buttons below!
========================================================================
guest@net-sandbox:~$

Instant Execution Presets (Click to Run):

Structured Troubleshooting Workflow Matrix

Step 01Reachability

Layer 3 ICMP Ping Test

Verify IP layer connectivity and physical/link layer reachability.

Step 02Path Analysis

Hop Path & Delay Pinpoint

Identify exact router hop or provider link dropping packets.

Step 03DNS Audit

DNS Resolution Audit

Confirm whether issue is IP routing or domain name resolution failure.

Step 04Port Security

Firewall & Port Check

Detect blocked TCP/UDP ports, stateful firewall drops, or down services.

Step 05Throughput

Bandwidth & Throughput

Measure maximum transmission rate, TCP window size, and UDP packet loss.

Diagnostic Tools Command Cheat Sheet

Comprehensive reference of syntax, flags, OSI layers, and practical use-cases.

ping (Packet InterNet Groper)ICMP / Layer 3

Sends ICMP Echo Request packets to verify end-to-end IP reachability, latency (RTT), and packet loss percentage.

Syntax:ping [options] <destination_ip_or_hostname>
Key Command Options & Flags:
-c <count>Stop after sending specified number of ECHO_REQUEST packets.
-i <interval>Wait specified seconds between sending each packet (default: 1s).
-s <bytes>Specify number of payload data bytes to send (useful for MTU test).
-t <ttl>Set IP Time To Live (TTL) hop count limit.
Practical Use-Case: Quick sanity check for gateway reachability and testing MTU fragment limits without path discovery.
traceroute / tracertICMP & UDP / Layer 3

Maps every intermediate router hop along the packet path by incrementing IP TTL field from 1 up to destination.

Syntax:traceroute [options] <destination_host>
Key Command Options & Flags:
-nPrint hop addresses numerically without executing slow DNS reverse lookups.
-m <max_ttl>Set maximum number of hops (TTL) to search (default 30).
-IUse ICMP ECHO requests instead of default UDP datagrams.
-p <port>Specify destination base port for UDP probes.
Practical Use-Case: Isolating which specific ISP router or inter-subnet hop is introducing latency spikes or packet drops.
mtr (My TraceRoute)ICMP & UDP / Layer 3

Combines the functionality of ping and traceroute into a single continuous real-time network diagnostic tool.

Syntax:mtr [options] <target_host>
Key Command Options & Flags:
-rReport mode: output continuous stats after running set packet count.
-c <count>Set number of pings sent per hop before generating final report.
-wWide report mode: print full hostnames without truncating.
-nNo DNS resolution on hop IP addresses.
Practical Use-Case: Generating non-interactive diagnostic reports for ISPs to prove intermittent packet loss over time.
iperf3 (Bandwidth Benchmark)TCP & UDP / Layer 4

Measures maximum attainable TCP and UDP network bandwidth, packet jitter, and datagram loss between two hosts.

Syntax:iperf3 -c <server_ip> [options] | iperf3 -s
Key Command Options & Flags:
-c <host>Run in client mode, connecting to specified iperf3 server host.
-sRun in server daemon mode listening for incoming benchmark connections.
-p <port>Set server port to listen/connect on (default 5201).
-uUse UDP packets instead of default TCP streams for jitter/loss test.
-b <rate>Set target UDP bandwidth constraint (e.g. 1G, 100M).
Practical Use-Case: Verifying actual throughput capacity across VPN tunnels, 10GbE links, or Wi-Fi subnets.
dig (Domain Information Groper)DNS / Layer 7

Flexible DNS lookup utility that queries Domain Name System servers directly and prints exact response records.

Syntax:dig [@server] <domain> [type] [options]
Key Command Options & Flags:
+shortPrint clean, concise answer records only without header noise.
+traceFollow authoritative DNS delegation path from root servers down.
@serverQuery specific DNS resolver IP instead of default system DNS.
ANY / A / MXSpecify query record type (A, AAAA, MX, NS, TXT, CNAME, SOA).
Practical Use-Case: Troubleshooting email routing failures, verifying DNS propagation, and auditing SPF/TXT records.
nmap (Network Mapper)TCP & UDP / Layer 4 & 7

Industry-standard port scanner and network security auditor used for host discovery and service enumeration.

Syntax:nmap [scan_type] [options] <target>
Key Command Options & Flags:
-sSTCP SYN Stealth Scan (half-open scan, does not complete 3-way handshake).
-sVProbe open ports to determine service name and software version info.
-p <ports>Scan target ports only (e.g. -p 22,80,443 or -p 1-1024).
-OEnable remote operating system fingerprint detection.
Practical Use-Case: Auditing firewall rule enforcement, finding rogue listening daemons, and mapping open subnet ports.
#routing

17. Routing & Gateway Protocols

Routers are the backbone of IP communications. They build forwarding decisions by evaluating packet destination addresses against local Routing Tables. Explore how routers learn paths dynamically via IGP & EGP Protocols, maintain seamless default gateway uptime with HSRP/VRRP Redundancy, condense massive ISP tables using BGP Aggregation, and execute Longest Prefix Matching.

Part 1

Static vs. Dynamic Routing Protocols

Code: OLink-State IGP

OSPF (Open Shortest Path First)

Admin Distance (AD)110
Multicast IP / Transport224.0.0.5 (All OSPF) / 224.0.0.6 (DR/BDR)

Medium to large enterprise networks requiring fast convergence and hierarchical area design (Backbone Area 0).

AlgorithmDijkstra's Shortest Path First (SPF)
Metric CalculationCost = 100,000,000 / Bandwidth (bps)
Convergence SpeedFast (Sub-second with BFD)
Deployment ScopeInterior Gateway Protocol (IGP) / Enterprise LAN/WAN
Key Technical Highlights
Hierarchical structuring via Area 0 (Backbone) and stub areas.
Sends Link-State Advertisements (LSAs) only on topology changes.
Elects Designated Router (DR) and Backup Designated Router (BDR) on multi-access networks.
Open IETF standard protocol (RFC 2328).

Administrative Distance (AD) Trust Hierarchy (Lower = Better)Believability Score (0 - 255)

0
Connected
1
Static
20
eBGP
90
EIGRP
110
OSPF
120
RIP
200
iBGP
Part 2

Gateway Redundancy (HSRP & VRRP Virtual IP Failover)

Shared First-Hop Gateway (HSRP)
VIP: 192.168.1.1(VMAC: 0000.0C07.AC01)
Router A (R1)ACTIVE
Phys IP: 192.168.1.2
Priority: 110
Hello: Every 3s
Forwarding LAN Traffic
Router B (R2)STANDBY
Phys IP: 192.168.1.3
Priority: 100
Hold Timer: 10s
Listening for R1 Heartbeats
LAN Client HostIP: 192.168.1.50
Configured Default Gateway: 192.168.1.1 (Unaware of physical router swap!)

Interactive Failover Controls

Primary Router A StatusLink UP & Healthy
Preemption ModeForces highest priority router back to Active upon recovery
Protocol Event Console Log
12:00:00 - Initial state: Router A is ACTIVE/MASTER (Priority 110). Router B is STANDBY/BACKUP (Priority 100).
12:00:00 - Virtual IP 192.168.1.1 bound to Virtual MAC (0000.5E00.0101). Serving LAN Host 192.168.1.50.
Part 3

BGP Route Summarization & Aggregation

BGP aggregate-address

Reducing Global Routing Table Bloat

The Internet routing table contains over 900,000 IPv4 prefixes. To protect router RAM and CPU, Autonomous Systems summarize contiguous subnets into a single prefix before advertising to ISP peers.

Original Routes:4 prefixes
Aggregated Block:198.51.100.0/22
Table Reduction:-75% route entries

Bitwise Matching Breakdown (22 Common Bits)Green = Identical Network Bits

198.51.100.0/24
11000110001100110110010000000000
198.51.101.0/24
11000110001100110110010100000000
198.51.102.0/24
11000110001100110110011000000000
198.51.103.0/24
11000110001100110110011100000000
! Cisco IOS BGP Aggregation Configuration
router bgp 65001
network 198.51.100.0 mask 255.255.255.0
network 198.51.101.0 mask 255.255.255.0
network 198.51.102.0 mask 255.255.255.0
network 198.51.103.0 mask 255.255.255.0
aggregate-address 198.51.100.0 255.255.252.0 summary-only as-set
Part 4

Interactive Routing Table Lookup Simulator (Longest Prefix Match)

Quick Test IPs
🎯Selected Route: 10.0.1.48/29 via 10.0.1.49 (Eth1.20)
Longest Prefix: /29

Matched 6 route entries. Subnet mask /29 won because it has the highest number of contiguous matching network bits (Longest Prefix Match Rule).

Active Router Forwarding Information Base (FIB)

Total Entries: 8
StatusProtocolNetwork CIDRNext Hop IPInterfaceAD / MetricAction
★ SELECTEDEIGRP10.0.1.48/2910.0.1.49Eth1.2090 / 15
MATCHED (/27)Static10.0.1.32/2710.0.1.1Eth1.101 / 1
MATCHED (/24)Connected10.0.1.0/2410.0.1.1Eth10 / 0
MATCHED (/16)OSPF10.0.0.0/1610.255.1.1Eth0110 / 10
MATCHED (/8)OSPF10.0.0.0/810.255.0.1Eth0110 / 20
NO MATCHConnected192.168.1.0/24192.168.1.1Eth20 / 0
NO MATCHBGP172.16.0.0/12172.16.0.1Eth320 / 100
MATCHED (/0)Static0.0.0.0/0203.0.113.1WAN01 / 1

Add Custom Route Entry to Table

#dhcp-ipam

19. DHCP & IP Address Management (IPAM)

Dynamic Host Configuration Protocol (DHCP) automates IPv4/IPv6 allocation across local networks. Explore the step-by-step DORA handshake, Layer 3 relay agent forwarding across subnets, core DHCP options, and enterprise IPAM pool sizing.

Interactive Protocol Flow

The 4-Step DORA Handshake

UDP Ports: Server 67 | Client 68
💻
Client Workstation
MAC: 00:1A:2B:3C:4D:5E
IP: 0.0.0.0
Direction: Client WorkstationDHCP Server / Broadcast
0.0.0.0:68
D
255.255.255.255:67
Type: BroadcastDst MAC: FF:FF:FF:FF:FF:FF
🖥️
DHCP Server
IP: 192.168.10.1
Listening UDP 67

DHCP DISCOVER Summary

When an unconfigured device connects to a network, it has no IP address. It sends a Layer 3 UDP broadcast to 255.255.255.255 on port 67. Since the client has no IP yet, its source IP is 0.0.0.0 and UDP source port is 68.

Packet Header Payload
Source MAC: 00:1A:2B:3C:4D:5E
Dest MAC: FF:FF:FF:FF:FF:FF
Source IP: 0.0.0.0
Dest IP: 255.255.255.255

Payload Parameters & Options

Option 53DHCP Message Type = Discover (1)Identifies the packet type
Option 55Parameter Request List (1, 3, 6, 15, 121)Options client is asking for
Option 61Client Identifier (MAC)Unique hardware identity
Option 12Host Name = 'MacBook-Pro'Client hostname declaration
Step 1 of 4
Cross-Subnet Forwarding

DHCP Relay Agent (ip helper-address)

VLAN 10 Subnet (192.168.10.0/24)
💻
Client Host
Sends L3 Broadcast:
255.255.255.255:67
L3 Router (Gateway 192.168.10.1)
🛣️
Interface G0/0.10
✓ Converts Broadcast to Unicast to 10.0.0.100 (GIADDR: 192.168.10.1)
Central Management Subnet
🖥️
Central DHCP Server
IP: 10.0.0.100
Receives Unicast & Allocates from Pool 192.168.10.0/24
Why DHCP Relay is Required: Routers drop Layer 3 broadcast packets (255.255.255.255) by default to prevent broadcast storms. When clients reside on separate VLANs from the central DHCP server, the router's interface acts as a DHCP Relay Agent. It intercepts the local broadcast, sets the GIADDR (Gateway IP Address) field to 192.168.10.1, and forwards a unicast packet across subnets directly to 10.0.0.100.
Cisco IOS Relay Agent Configuration
! Cisco IOS DHCP Relay Agent Configuration
! 1. Enter Gateway Subnet Interface (VLAN 10)
interface GigabitEthernet0/0.10
 description LAN-VLAN10-GATEWAY
 ip address 192.168.10.1 255.255.255.0

! 2. Configure Primary & Secondary DHCP Server Relays
! Helper-address converts L2/L3 Broadcasts into Unicast to target IP
 ip helper-address 10.0.0.100
 ip helper-address 10.0.0.101

! 3. (Optional) Fine-tune Relay Security & Option 82 Insertion
 ip dhcp relay information option
 ip dhcp relay information trust-all
Network Configuration Parameters

Essential DHCP Options

Option 1Subnet Mask
0x01

Specifies the subnet mask of the client's subnet according to dotted decimal notation.

Sample Payload: 255.255.255.0
Data Length: 4 bytes | RFC 2132 Section 3.3
Enterprise Use Case: Defines network vs host portion boundary for routing decisions.
Option 3Router (Default Gateway)
0x03

List of IP addresses for routers on the client's subnet. Must be listed in preference order.

Sample Payload: 192.168.10.1
Data Length: 4 * n bytes | RFC 2132 Section 3.5
Enterprise Use Case: Allows hosts to route traffic destined for external networks and the Internet.
Option 6Domain Name Server (DNS)
0x06

List of DNS recursive name servers available to the client.

Sample Payload: 10.0.0.10, 1.1.1.1
Data Length: 4 * n bytes | RFC 2132 Section 3.8
Enterprise Use Case: Directs client domain name lookups to internal Active Directory DNS and public fallbacks.
Option 12Host Name
0x0C

Specifies the name of the client host, often populated automatically into Dynamic DNS (DDNS).

Sample Payload: 'FINANCE-PC-042'
Data Length: Variable | RFC 2132 Section 3.14
Enterprise Use Case: Enables corporate DNS servers to auto-register hostnames for internal resolution.
Option 15Domain Name
0x0F

Specifies the domain name that client should use when resolving unqualified hostnames.

Sample Payload: 'corp.internal.example.com'
Data Length: Variable | RFC 2132 Section 3.17
Enterprise Use Case: Allows staff to type 'server01' and automatically expand to 'server01.corp.internal'.
Option 66TFTP Server Name (PXE)
0x42

Identifies TFTP boot server used for PXE network operating system deployment.

Sample Payload: '10.0.0.50' / 'tftp.corp.net'
Data Length: Variable | RFC 2132 Section 9.4
Enterprise Use Case: Used by WDS / SCCM / iPXE to automate OS installation over bare-metal network boot.
Option 67Bootfile Name (PXE)
0x43

Specifies the executable filename location on the TFTP server to initiate PXE boot.

Sample Payload: 'pxelinux.0' / 'boot\x64\wdsmgfw.efi'
Data Length: Variable | RFC 2132 Section 9.5
Enterprise Use Case: Instructs UEFI / BIOS firmware which NBP (Network Boot Program) binary to load.
Option 121Classless Static Routes
0x79

Injects specific static routing table entries directly into client operating systems.

Sample Payload: Dst: 10.50.0.0/16 -> Gateway: 192.168.10.254
Data Length: Variable | RFC 3442
Enterprise Use Case: Directs internal VPN / MPLS traffic to dedicated security gateways without overriding default Internet gateway.
Capacity & Planning

Enterprise IPAM & Pool Exhaustion Calculator

HIGH UTILIZATION WARNING
Pool Allocation Distribution80.4% Utilization
Static Reserved: 30
Active Leases: 180
Free Available: 44
Total Usable Pool Size
224 IPs
Excluding network & broadcast address
Available Free Pool
44 IPs
Unallocated available leases
Est. Time to Pool Exhaustion
23.5 Hours
Based on daily device churn rate
💡 IPAM Health Recommendation

WARNING: High pool usage. High churn during peak hours may trigger address depletion.

Best Practice Tip: For guest Wi-Fi networks with high turnover, set lease duration to 2 to 4 hours. For enterprise office desktops, set lease duration to 8 days.
#packets

20. Packet Encapsulation & Analysis

Every interaction on the internet depends on Packet Encapsulation—the process where raw application data is wrapped layer-by-layer with Transport headers, IP headers, and Ethernet frames before physical transmission over the wire. Understanding header bit fields, stateful TCP handshakes, and PCAP analysis tools like Wireshark is essential for network engineering and security analysis.

1. Interactive OSI vs TCP/IP Layer Stack Inspector

Select any layer to inspect protocol mapping, PDU names, headers attached, and addressing units.

Encapsulation Step:Data
📦
PDU Encapsulation State
1. Application Data (HTTP GET /index.html)
Payload: GET /index.html
OSI 7-Layer ModelTCP/IP 4-Layer Equivalent
OSI Layer 4

Transport Layer

Transport Layer

Provides end-to-end process-to-process data delivery, flow control, error recovery, and multiplexing.

Protocol Data Unit (PDU)
Segment (TCP) / Datagram (UDP)
Addressing Scheme
Port Numbers (e.g. Src: 54321, Dst: 443)
Encapsulation Header / Trailer Action
Transport Header (Src/Dst Ports, Seq/Ack, Flags, Checksum)
Key Protocols & Standards
TCPUDPSCTPQUIC
Encapsulation Direction: Top-Down (L7 → L1)Decapsulation: Bottom-Up (L1 → L7)

2. Frame, Packet & Segment Header Anatomy

RFC Bit/Byte layout visualizer for Ethernet II Frames (Layer 2), IPv4 Packets (Layer 3), and TCP Segments (Layer 4).

Bit Offset: 0Bit 15Bit 31 (32-Bit Width Word)

Data Offset (4b) + Flags (9b)

Offset: 12-13 (2 Bytes) (16 bits)

Data Offset defines header size in 32-bit words. Control Flags control session state (URG, ACK, PSH, RST, SYN, FIN).

Sample Hex Raw Bytes:80 02
Decoded / Value:Header Len: 32B | Flags: SYN=1

3. TCP 3-Way Handshake & Connection Teardown

Step-by-step TCP sequence number arithmetic, flag bitmask inspection, and TCP socket state transitions.

💻
Client Host
192.168.1.50 : 54321
State: SYN_SENT
🌐
Web Server
93.184.216.34 : 443
State: LISTEN → SYN_RCVD
TCP SYN Segment
Direction: Client ➔ Server
TCP Control Flags BitmaskHeader Field
URG
0
ACK
0
PSH
0
RST
0
SYN
1
FIN
0
Sequence Num (Seq):1000
Ack Num (Ack):0

Step Explanation: Client picks an Initial Sequence Number (ISN=1000), sets SYN=1 flag, and sends connection request to Server port 443.

4. Interactive Wireshark PCAP Packet Viewer Simulator

Inspect real network trace packets, expand nested protocol headers, and analyze byte hex dumps.

Wireshark Packet Capture Trace - capture_01.pcap
Apply a display filter:
No.Time (s)SourceDestinationProtocolLengthInfo
10.000000192.168.1.5093.184.216.34TCP7454321 → 80 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 SACK_PERM=1
20.02411593.184.216.34192.168.1.50TCP7480 → 54321 [SYN, ACK] Seq=0 Ack=1 Win=29200 Len=0 MSS=1460
30.024210192.168.1.5093.184.216.34TCP6654321 → 80 [ACK] Seq=1 Ack=1 Win=64240 Len=0
40.025102192.168.1.5093.184.216.34HTTP144GET /index.html HTTP/1.1
50.026401192.168.1.501.1.1.1DNS83Standard query 0x1a2b A api.example.com
60.038920192.168.1.508.8.8.8ICMP98Echo (ping) request id=0x1234, seq=1, ttl=64
Packet Details Tree (Packet #1)
Encapsulation type: Ethernet (1)
Arrival Time: Aug 8, 2026 14:22:01.000000000 UTC
Frame Length: 74 bytes (592 bits)
Capture Length: 74 bytes (592 bits)
Destination: Router_70:3a:0e (70:3a:0e:99:88:77)
Source: Apple_00:1a:2b (00:1a:2b:3c:4d:5e)
Type: IPv4 (0x0800)
0100 .... = Version: 4
.... 0101 = Header Length: 20 bytes (5)
Total Length: 60 bytes
Identification: 0x1c46 (7238)
Flags: 0x4000, Don't fragment
Time to Live: 64
Protocol: TCP (6)
Header Checksum: 0x7c2d [validation disabled]
Source Address: 192.168.1.50
Destination Address: 93.184.216.34
Source Port: 54321
Destination Port: 80
Sequence Number: 0 (raw: 983503360)
Acknowledgment Number: 0
1000 .... = Header Length: 32 bytes (8)
Flags: 0x002 (SYN)
Window: 64240
Checksum: 0xe2a1 [correct]
TCP Options: (12 bytes) MSS=1460, SACK_PERM=1
Packet Bytes (Hex Dump)Selected Range: 34 - 74 Bytes
000070 3A 0E 99 88 77 00 1A 2B 3C 4D 5E 08 00 45 00p:...w..+<M^..E.
001000 3C 1C 46 40 00 40 06 7C 2D C0 A8 01 32 5D B8.<.F@.@.|-...2].
0020D8 22 D4 31 00 50 3A 9F 12 00 00 00 00 00 80 02.".1.P:.........
0030FA F0 E2 A1 00 00 02 04 05 B4 04 02 08 0A 00 00................
004000 00..
Packets: 6 • Displayed: 6Profile: Default Wireshark Decoders Active
#wireless

23. Wireless & WLAN Integration

Modern Enterprise Wireless LANs (WLANs) seamlessly bridge unguided RF radio signals to wired Ethernet infrastructures. This section explores SSID-to-VLAN mapping, Wireless LAN Controller (WLC) topologies, RF spectrum frequency bands (2.4GHz, 5GHz, 6GHz), Channel Bonding, and real-time Signal Propagation & Interference dynamics.

Part 1 ArchitectureCAPWAP & 802.1Q Trunking

SSID-to-VLAN Mapping & WLC Topology

Live Frame Flow for SSID: Corp-Enterprise

CAPWAP Data Tunneling (UDP 5247)
Step 1: Client
Wi-Fi Device
802.11 Radio Frame
SSID: Corp-Enterprise
Step 2: Access Point
Enterprise AP
Encapsulate CAPWAP
CAPWAP Payload
Step 3: WLC
Wireless Controller
Strip CAPWAP & Tag 802.1Q
Dot1Q Tag: VLAN 10
Step 4: L3 Gateway
Core Switch / Router
Default Gateway SVI
10.10.0.1
Authentication:
802.1X RADIUS (EAP-TLS)
Subnet CIDR:
10.10.0.0/24
QoS & Priority:
High (DSCP EF / Voice & Video)
ACL Policy:
Full Access to Internal LAN & ERP

Centralized WLC (Split MAC Architecture)

CAPWAP Tunnel

AP handles real-time 802.11 beaconing and frame acknowledgments (Local MAC). All user data packets are encapsulated in CAPWAP tunnels (UDP 5247) and sent to the WLC. WLC performs centralized 802.1X authentication, L2 VLAN tagging, and firewall policy enforcement.

FlexConnect (Local Switching Architecture)

Branch & Remote APs

Designed for branch offices over WAN. Management and control traffic (CAPWAP Control UDP 5246) goes to the central WLC, but user payload traffic is switched locally onto the local switch VLANs. If WAN disconnects, branch APs remain operational locally.

Part 2 Spectrum Analysis2.4 GHz vs 5 GHz vs 6 GHz (Wi-Fi 6E/7)

Wi-Fi Frequency Bands & Technical Comparison

2.4 GHz Band (Legacy & IoT)

2.412 - 2.484 GHz (~83.5 MHz)
Max Channel Width:
20 MHz (40 MHz not recommended)
Max PHY Speed:
Up to 286 - 1,148 Mbps (Wi-Fi 6 4x4)
Range & Wall Penetration:
Excellent (Passes through concrete & drywall easily)
Interference Risk:
Extremely High (Microwaves, Bluetooth, Zigbee, Baby monitors)
Non-Overlapping Channels:
3 Non-overlapping (1, 6, 11 @ 20MHz)
Key Technologies:
DSSS / CCK (802.11b), OFDM (802.11g/n), OFDMA (802.11ax)
Advantages
  • Maximum signal range and wall penetration
  • Compatible with 100% of Wi-Fi hardware
Disadvantages & Limitations
  • Only 3 non-overlapping channels (Heavy congestion)
  • Severe Bluetooth & Microwave interference
Specification / Metric2.4 GHz Band5 GHz Band6 GHz Band (Wi-Fi 6E/7)
Frequency Range2.412 - 2.484 GHz5.150 - 5.850 GHz5.925 - 7.125 GHz
Total Spectrum Pool~83.5 MHz~500 MHz~1,200 MHz (Massive)
20MHz Non-Overlapping Ch.3 Channels (1, 6, 11)Up to 25 ChannelsUp to 59 Channels
Max Supported Channel Width20 MHz (40MHz unsafe)20 / 40 / 80 / 160 MHzUp to 320 MHz (Wi-Fi 7)
Indoor Coverage Distance~35m (High penetration)~25m (Moderate penetration)~15m (Line-of-sight preferred)
Interference SourcesMicrowaves, Bluetooth, ZigbeeDFS Weather RadarsZero Legacy Devices (Clean)
Max Theoretical PHY Speed1.1 Gbps (Wi-Fi 6)9.6 Gbps (Wi-Fi 6)46.1 Gbps (Wi-Fi 7 MLO)
Part 3 Channel PlanningChannels 1, 6, 11 & Bonding Tree

2.4 GHz Channel Planner & 5/6 GHz Bonding

2.4 GHz Channel Overlap Calculator (Channels 1 to 11)20 MHz Width / 5 MHz Spacing

Ch 1 (2412MHz)Ch 6 (2437MHz)Ch 11 (2462MHz)
Ch 1 (2412MHz)Ch 6 (2437MHz)Ch 11 (2462MHz)
Calculated Interaction:Clean / Zero Overlap (Optimal)

Channels are separated by at least 25 MHz (5 channel numbers). Zero spectral overlap. Optimal cellular AP deployment!

Ch 1Ch 2Ch 3Ch 4Ch 5Ch 6Ch 7Ch 8Ch 9Ch 10Ch 11
AP1
AP2
Green shaded zones indicate standard non-overlapping channels (1, 6, 11).

5 GHz & 6 GHz Channel Bonding Hierarchy

Combines contiguous 20MHz channels to multiply throughput at the expense of spectrum density and SNR.

Base 20 MHz Channels:
Ch 36
Ch 40
Ch 44
Ch 48
Ch 52 (DFS)
Ch 56 (DFS)
Ch 60 (DFS)
Ch 64 (DFS)
Bonded 40 MHz Channels:
Ch 38 (36+40)
Ch 46 (44+48)
Ch 54 (52+56 DFS)
Ch 62 (60+64 DFS)
Bonded 80 MHz Channels:
Ch 42 (36+40+44+48)
Ch 58 (52+56+60+64 DFS)
Thermal Noise Penalty: Doubling channel width doubles noise floor (+3 dB noise).
+6 dB Noise
Part 4 SimulatorRSSI, Noise Floor, SNR & Spectrum Mask

Interactive Wi-Fi Signal & Spectrum Overlap Visualizer

1. Transmitter & Environment

TX Power:20 dBm (100 mW)
Distance:15 meters

2. AP Channels & Noise

3. Derived Signal Quality

Path Loss (FSPL):-74 dB
RSSI (Signal):-54 dBm
Signal-to-Noise (SNR):36 dB
Est. MCS Index:MCS 11 (Wi-Fi 6) (1024-QAM)
Max PHY Throughput:1201 Mbps
Excellent (Pristine Link)

Real-Time RF Spectrum Mask & Signal Shape

No Overlap
Noise Floor (-90 dBm)AP1 (Ch 36)AP2 (Ch 40)
Frequency StartPrimary Operating ChannelsFrequency End
#security

18. Network Security & Access Control

Modern cloud and enterprise networks enforce defense-in-depth through multi-layered access control mechanisms. From Stateless Subnet NACLs and Stateful Instance Security Groups to Encapsulated Overlay Tunnels (VPN & VXLAN) and Network Address Translation (NAT), secure network architectures protect workloads at every hop.

Layer 3/4 Filtering

1. Network ACLs vs. Security Groups

Comparing subnet-level stateless packet filters against hypervisor/ENI stateful firewalls.

Architectural FeatureNetwork ACL (NACL)Security Group (SG)
Operating BoundarySubnet Boundary (VPC Router Level)Instance / ENI Level (Hypervisor)
State TrackingStateless

Return traffic MUST be explicitly allowed in Outbound rules.

Stateful

Return traffic automatically allowed regardless of outbound rules.

Rule Actions SupportedALLOW and DENY rulesALLOW rules only (Implicit Default Deny)
Evaluation OrderSequential by Rule Number (Lowest number evaluated first)All rules evaluated simultaneously before decision
Ephemeral Return PortsMust open ports 1024-65535 outbound for response traffic!Automatically tracked by connection state table

Return Traffic Flow Breakdown — NACL (Stateless)Step 1 of 3

[PACKET INBOUND]Src: 203.0.113.50:52134 → Dst: 10.0.1.10:80

External client sends HTTP request to web server on port 80 using client ephemeral port 52134.

NACL Check: Inbound Rule 100 permits TCP Port 80 → Packet allowed into Subnet.
Site-to-Site & Remote Access

VPN Tunnels

WireGuard — Modern Lightweight Crypto Tunnel

Designed as a fast, simple replacement for IPsec and OpenVPN. Operates in Linux kernel space with minimal overhead (~4,000 lines of code).

Crypto Primitive:ChaCha20-Poly1305 & Curve25519
Handshake Protocol:Noise Protocol Framework (1 RTT)
Transport Layer:UDP Port 51820
Key Exchange:Static Public Keys (Cryptokey Routing)
Roaming Ability:Seamless IP Roaming across Wi-Fi/Cellular
Overlay Network (L2 over L3)

VXLAN Encapsulation

UDP 4789

Virtual Extensible LAN (VXLAN) encapsulates Layer 2 Ethernet frames inside Layer 4 UDP packets. Used in data center spine-leaf topologies and Kubernetes CNI overlays (Flannel/Calico) to expand past the 4,096 VLAN limit up to 16.7 Million VNI segments.

Click Packet Header Layer to Inspect Encapsulation:
4. VXLAN HeaderHeader Size: 8 Bytes
Flags (I=1) | Reserved (24b) | VNI: 5001 (24-bit) | Reserved (8b)

Contains the 24-bit VXLAN Network Identifier (VNI) providing up to 16,777,216 isolated virtual Layer 2 subnets over a shared L3 fabric.

Address Translation Architecture

3. Network Address Translation (NAT) Variants

Understanding SNAT, DNAT, and PAT (NAPT) packet header transformations at boundary gateways.

Many-to-One Overload NAT

PAT — Port Address Translation

Maps thousands of internal private host IP addresses onto a single shared public IP address by assigning unique public source ports for each session.

Primary Use Case: Home Routers, Corporate Egress Gateways, IPv4 Address Preservation.
PAT Translation Table Mapping (Multiple Internal Hosts → 1 Public IP):
Host A (10.0.1.15:5000)203.0.113.1:10001
Host B (10.0.1.16:5000)203.0.113.1:10002
Host C (10.0.1.17:5000)203.0.113.1:10003

Both source IP and source port are translated to prevent socket collisions on public internet responses.

Interactive Testing Suite

4. Interactive Security Rule Inspector

Test arbitrary packet parameters (Source IP, Destination Port, Protocol) against custom firewall ACLs.

Testing packet: TCP packet to port 80 from 203.0.113.50.

✓ PACKET PERMITTED (ALLOWED)Mode: NACL

Matched explicitly enabled Rule #100 (Allow inbound HTTP from internet). Evaluation halted (First Match Wins).

Rule Engine Evaluation Trace:
Rule #100 MATCHED: [Protocol: TCP, Port: 80, Source: 0.0.0.0/0] → Action: ALLOW

Active NACL Rule ConfigurationClick rule checkbox to enable/disable

ActiveRule #ProtocolPort RangeSource CIDRActionDescription
#100TCP800.0.0.0/0ALLOWAllow inbound HTTP from internet
#110TCP4430.0.0.0/0ALLOWAllow inbound HTTPS from internet
#200TCP22192.168.1.0/24ALLOWAllow SSH only from Admin Subnet
#210TCP220.0.0.0/0DENYDeny SSH from everywhere else
#300TCP330610.0.1.0/24ALLOWAllow MySQL from Web Subnet
#999ALLALL0.0.0.0/0DENYDefault Deny All Inbound Traffic
Add Custom Rule to NACL Table: