A subnet is a logical partition of an IP network into smaller, manageable segments. This division is achieved by applying a subnet mask to an IP address, which distinguishes the network identifier from the host identifier. Subnetting is essential for organizing address spaces in both IPv4 and IPv6 infrastructures.
Routers use subnet masks to define the boundaries of broadcast domains. When a data packet is transmitted, the device compares the destination IP with its own subnet mask. If the destination is within the same subnet, the packet is delivered locally via L2 protocols; otherwise, it is forwarded to the default gateway for L3 routing.
How it works
- Traffic Isolation: Reduces network congestion by limiting the scope of broadcast packets.
- Security: Enables the implementation of Access Control Lists (ACLs) to isolate sensitive resources, such as database servers, from public access.
- Address Management: Facilitates efficient use of IP address space through Classless Inter-Domain Routing (CIDR).
For example, a 192.168.1.0/24 network can be divided into two subnets with a /25 mask (255.255.255.128). This creates two ranges: .1 to .126 and .129 to .254. Each subnet requires its own network address and broadcast address, which are reserved and cannot be assigned to hosts.