IPv4 Subnetting, CIDR Blocks, IPv6 Addressing, and ASN Lookups for Cloud and DevOps Engineers
Mis-sized VPC subnets, overlapping VPN routes, broken firewall ACLs, and misread IP blocks cause some of the hardest cloud infrastructure re-architectures—because once production databases and Kubernetes clusters run inside an IP block, renumbering everything without downtime is painful.
You do not need to memorize binary conversion tables to engineer reliable networks, but you do need rock-solid command of CIDR boundaries, reserved ranges, IPv6 notation, and public routing lookups.
IPv4 CIDR Math Without Binary Headaches
Classful networks (Class A/B/C) died in the 1990s, yet legacy habits remain. Modern routing runs strictly on CIDR (Classless Inter-Domain Routing) notation such as 10.20.4.0/22, where the prefix number (/22) tells routers how many leading bits out of 32 identify the network versus individual hosts.
The Core Formula—and the /31 and /32 Exceptions
For standard LAN and VPC subnets up to /30, total IP addresses equal 2^(32 - prefix), and usable host addresses equal 2^(32 - prefix) - 2. Those two reserved endpoints are always:
- Network ID (all host bits set to
0—the very first IP in the block). - Broadcast address (all host bits set to
1—the very last IP in the block).
Quick reference for the blocks engineers slice daily:
/24(mask255.255.255.0):256total IPs ->254usable hosts./26(mask255.255.255.192):64total IPs ->62usable hosts (4 subnets per/24)./28(mask255.255.255.240):16total IPs ->14usable hosts (common for small load balancer or bastion tiers)./30(mask255.255.255.252):4total IPs ->2usable hosts (traditional router point-to-point links)./31(RFC 3021 exception):2total IPs ->2usable hosts! On modern router point-to-point links without broadcast traffic, both addresses are usable./32(host route):1IP ->1usable address, used in security groups (203.0.113.45/32), loopback interfaces, and BGP host advertisements.
Rather than guessing subnet boundaries in your head during a firewall change window, verify network ID, broadcast address, wildcard mask (needed for Cisco/firewall inverse ACLs), and first/last usable host with a CIDR Calculator, Subnet Calculator, or IPv4 Calculator. When auditing legacy security rules given only start and end IPs (192.168.10.0 to 192.168.10.63), convert cleanly using an IP Range Calculator.
Cloud VPC Sizing and Avoiding Private Range Collisions
Most teams start their first cloud VPC with 10.0.0.0/16 or 192.168.0.0/16 and regret it two years later when acquiring a partner, launching multi-region peering, or configuring employee VPNs. Follow three practical cloud-sizing rules:
- Know the private vs. shared IPv4 allocations: Standard RFC 1918 private space comprises
10.0.0.0/8,172.16.0.0/12(172.16.0.0–172.31.255.255), and192.168.0.0/16. Avoid192.168.0.0/24and192.168.1.0/24in corporate infrastructure—half your remote developers have home Wi-Fi routers on those exact prefixes, which collides instantly with split-tunnel VPNs. - Recognize RFC 6598 (
100.64.0.0/10): Originally reserved for Carrier-Grade NAT (CGNAT) inside ISP networks, you now also see100.64.0.0/10powering modern mesh overlay VPNs like Tailscale and cloud service meshes. Never treat100.64.0.0/10as routable public internet space or random RFC 1918 space. - Account for cloud-provider IP overhead: On AWS, Azure, or GCP, every VPC subnet reserves 4 to 5 addresses, not 2 (network ID, VPC router, internal DNS resolver, future-use reservation, broadcast). A
/28block (16 IPs) yields only 11 usable elastic interfaces on AWS—far too tight for rolling Lambda ENIs or Kubernetes pods! Allocate/24to/22for worker subnets and keep spare contiguous CIDRs documented per environment (dev,staging,prod-us-east,prod-eu-central) so VPC peering never overlaps.
IPv6 Addressing Decoded for IPv4 Engineers
IPv6 expands addresses from 32 bits to 128 bits, written as eight 4-hex-digit groups (hextets) separated by colons—for example, the documentation prefix 2001:0db8:85a3:0000:0000:8a2e:0370:7334.
Compression Rules That Trip Up Regex and Firewall Configs
Two strict formatting rules keep shorthand IPv6 addresses unambiguous:
- Strip leading zeros inside each group:
0db8becomesdb8, and0000becomes0. Never strip trailing zeros (8a2estays8a2e, and0db0becomesdb0, notdb). - Collapse contiguous
0groups using::at most once: Multiple zero blocks compress cleanly (2001:db8:85a3::8a2e:370:7334), but::may appear only once per address, otherwise receivers cannot calculate how many 16-bit groups were omitted.
Why IPv6 Subnets Default to /64
Unlike IPv4—where engineers hoard /29 and /28 slivers to save addresses—IPv6 subnets almost universally end at /64 (providing 64 interface bits). Stateless Address Autoconfiguration (SLAAC), privacy extensions, and standard neighbor discovery expect a /64 host boundary. Enterprise sites typically receive /48 (65,536 /64 subnets) or /56 (256 /64 subnets). Inspect compressed/expanded forms and prefix boundaries accurately using an IPv6 Calculator.
Investigating Production Traffic: IP, ASN, PTR, and MAC Lookups
When suspicious traffic spikes hit your WAF logs, outbound mail starts bouncing, or a local rack host vanishes, four lightweight lookups turn raw addresses into actionable context:
- ASN & ISP Ownership (
Autonomous System Number): An IP geolocation flag alone often misleads you—cloud hosting nodes, VPN exit endpoints, and CDNs frequently announce blocks far away from their corporate headquarters. Running an ASN Lookup or ISP Lookup immediately tells you whether1,200 req/mincame from a residential consumer ISP, a known search crawler ASN, or a rented VPS provider (AS14061,AS16509, etc.) scraping your API. - IP Lookup & Geolocation Caveats: Use an IP Lookup and IP Geolocation for quick region/timezone routing checks—never for street-level fraud proof, because mobile carrier gateways and anycast CDNs skew city accuracy by hundreds of kilometers. (Public IP lookups query third-party GeoIP/ASN providers with the IP string you supply, as documented in our privacy standards.)
- Reverse DNS (
PTR) Records for Deliverability and Logs: Forward DNS mapsmail.example.com -> 198.51.100.12; a PTR record maps12.100.51.198.in-addr.arpa -> mail.example.com. Many enterprise mail gateways reject or penalize SMTP servers failing Forward-Confirmed Reverse DNS (FCrDNS). Verify PTR alignment with a Reverse DNS Lookup, and pair it with our SPF/DKIM/DMARC deliverability guide and DNS & TLS outage runbook. - MAC Prefix (OUI) Identification on Local LANs: Inside office switches, hypervisors, or homelabs, ARP tables only give
IP <-> MAC. The first 3 bytes (24 bits, e.g.,DC:A6:32) identify the network adapter manufacturer (OUI). A MAC Address Lookup helps distinguish a Raspberry Pi, VMware virtual NIC, or unauthorized plug-and-play IoT device—keeping in mind that modern phones and laptops intentionally randomize local Wi-Fi MACs by default.
Bottom line: Leave comfortable subnet headroom in cloud VPCs, keep RFC 1918 and CGNAT ranges collision-free, respect IPv6 /64 conventions, and combine CIDR math with ASN/PTR telemetry whenever diagnosing production network anomalies.
Try a free tool
Every tool runs in your browser with no account required.