Subnet
A slice of a network's IP addresses, grouped so its devices can talk directly.
A subnet is a block of consecutive IP addresses that belong together, like all the addresses on one office floor or in one part of a cloud network. Devices in the same subnet reach each other directly. To reach anything outside it, they hand their traffic to a router, known as the default gateway, which forwards it on.
Subnets are usually written in CIDR notation: 10.0.1.0/24. The number after the slash says how many of the 32 bits of an IPv4 address are fixed for the whole subnet; the rest are free for devices. A /24 fixes the first three numbers, so 10.0.1.0 to 10.0.1.255 is roughly 250 usable addresses. A /16 fixes only the first two and holds about 65,000. The bigger the number after the slash, the smaller the subnet. The older way to say the same thing is a subnet mask: /24 is 255.255.255.0.
Splitting a network has practical reasons. Each subnet can get its own rules, so a firewall can let the web servers in one subnet talk to the database in another, while the guest Wi-Fi in a third reaches only the internet. Smaller subnets also keep local chatter, like devices asking 'who has this address?', from flooding every machine in the building.
In the cloud this is everyday work. When you create an Amazon VPC you pick a range like 10.0.0.0/16 and carve it into subnets, typically one public and one private per Availability Zone. Public subnets hold what must be reachable from the internet, such as a load balancer; private ones hold databases and internal services. Ranges cannot overlap if networks will ever be connected, so it pays to plan them early.
Keep in mind
- Devices in the same subnet talk directly; anything else goes through the router.
/24means the first 24 bits are fixed: roughly 250 usable addresses.- A bigger number after the slash means a smaller subnet.
- In the cloud, public subnets face the internet and private ones stay inside.