How to compute subnet, CIDR and IP range of a network

Compute subnet mask, network and broadcast address, usable host range, IP class and scope (private/public) from IP/CIDR. RFC 4632, RFC 1918, VLSM. Corporate network examples.

Calculation parameters
Was this calculator useful?

How to compute subnet, CIDR and IP range of a network: given CIDR notation (e.g., 192.168.1.0/24), compute network address, broadcast address, first and last usable host, subnet mask, total addresses and usable hosts. CIDR (Classless Inter-Domain Routing, RFC 4632) replaces pre-1993 "classful" system (Classes A/B/C) with variable-length prefixes for efficient IPv4 use. Formula total addresses = 2^(32-prefix), usable hosts = total - 2 (reserving network and broadcast), except /31 (point-to-point RFC 3021) and /32 (single host). VLSM (Variable Length Subnet Mask) enables hierarchical subnetting. Essential tool for network engineering, sysadmin Cisco/MikroTik/Juniper, firewall configuration, VLAN, routing, troubleshooting, CCNA/CCNP/CCIE certification.

CIDR subnetting formulas

Decimal to binary conversion: each IP octet (0-255) is an 8-bit byte. Example 192.168.1.0 = 11000000.10101000.00000001.00000000. Subnet mask /24 = 11111111.11111111.11111111.00000000 = 255.255.255.0. Bitwise AND IP & mask = network address. OR with inverted wildcard = broadcast.

Network address: IP & subnet_mask. Host bits (after prefix) all 0. Example 192.168.1.50/24: 192.168.1.50 & 255.255.255.0 = 192.168.1.0. For /25 (more specific subnet): 192.168.1.50 & 255.255.255.128 = 192.168.1.0 (same) or 192.168.1.128 depending on IP. Network address is NOT assignable to host.

Broadcast address: network | wildcard_mask. Host bits all 1. For 192.168.1.0/24: broadcast 192.168.1.255. Packets directed to broadcast reach all subnet hosts (Layer 2 switch). Broadcast is NOT assignable to host. Limited broadcast 255.255.255.255 is broadcast for entire local network (DHCP discover).

Usable host range: from network+1 to broadcast-1. For /24 (256 addresses): 254 hosts (256 - network - broadcast). For /16 (65536 addresses): 65534 hosts. For /23 (512 addresses): 510 hosts (useful for supernetting). RFC 3021 exceptions: /31 point-to-point uses 2 IPs both assignable (router-router); /32 single host route (loopback, anycast).

Common CIDR prefix table: /8 = 16M IPs (one Class A), /16 = 65k IPs (entire Class B or large /16 office), /24 = 256 IPs (typical LAN), /25 = 128 IPs, /26 = 64 IPs (small office), /27 = 32 IPs, /28 = 16 IPs (small DMZ), /29 = 8 IPs (ISP customer subnet), /30 = 4 IPs (P2P link), /31 = 2 IPs (P2P RFC 3021), /32 = 1 IP (host route).

History and context

IP version 4 (IPv4) was standardized in 1981 by Vint Cerf and Bob Kahn (RFC 791) at DARPA. Initial "classful" system: Class A (/8 8 million IPs, 126 networks), Class B (/16, 65k IPs, 16k networks), Class C (/24, 254 IPs, 2 million networks). Rapid exhaustion motivated Classless Inter-Domain Routing (CIDR, RFC 1517-1520, 1993) introducing variable prefixes. RFC 1918 (1996, Rekhter et al) reserved 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 for private networks. RFC 4632 (2006) consolidated CIDR standard. RFC 3021 (2000) /31 point-to-point for IP saving. RFC 6598 (2012) Carrier-Grade NAT 100.64.0.0/10. IPv6 (RFC 8200, 2017) replaces IPv4 with 128 bits (3.4*10^38 addresses); slow transition, IPv4 exhausted by IANA 2011 (regional level 2011-2019 ARIN/RIPE/APNIC). Global networking industry > $350 billion (Cisco, Juniper, Arista, Huawei). Cisco CCNA/CCNP/CCIE certifies subnetting skills. US: FCC IP regulation, NIST SP 800-37 federal cybersecurity.

CIDR prefix and applications table

  • /8: 16,777,216 addresses, 16,777,214 hosts - entire Class A, tier-1 ISP
  • /16: 65,536 - 65,534 hosts - large enterprises, universities
  • /19: 8,192 - 8,190 hosts - large enterprise networks
  • /22: 1,024 - 1,022 hosts - office floor, stadium
  • /23: 512 - 510 hosts - voice + data combined VLAN
  • /24: 256 - 254 hosts - classic home/small office LAN
  • /25: 128 - 126 hosts - departments
  • /26: 64 - 62 hosts - conference room, IoT zone
  • /27: 32 - 30 hosts - small subnet
  • /28: 16 - 14 hosts - DMZ services
  • /29: 8 - 6 hosts - public ISP customer subnet
  • /30: 4 - 2 hosts - P2P router-router link
  • /31: 2 - 2 hosts - P2P RFC 3021 (no broadcast)
  • /32: 1 - 1 host - loopback, single anycast

Worked numerical examples

Example 1 - corporate LAN /24 New York office. CIDR 192.168.10.0/24. Network: 192.168.10.0. Broadcast: 192.168.10.255. Subnet mask: 255.255.255.0. Usable host range: 192.168.10.1 - 192.168.10.254 (254 hosts). Typical default gateway: 192.168.10.1. DHCP pool: 192.168.10.100-200. Reserved statics: 192.168.10.2-99 (servers, printers). RFC 1918 private compliance. Cisco IOS: int gigabitethernet 0/1, ip address 192.168.10.1 255.255.255.0.

Example 2 - /22 supernet AT&T Atlanta corporate. 10.20.0.0/22 = 1024 addresses, 1022 usable hosts. Network 10.20.0.0, broadcast 10.20.3.255. 4 included /24 subnets (10.20.0/24, 10.20.1/24, 10.20.2/24, 10.20.3/24). OSPF area 0 routing summary: announce 10.20.0.0/22 instead of 4 separate /24s (route aggregation). Reduces routing table in core routers.

Example 3 - point-to-point router-router /30. 172.16.255.0/30. Network 172.16.255.0, broadcast 172.16.255.3. Hosts: 172.16.255.1 and .2 (2 usable, /30 standard). For /31 (RFC 3021) both 172.16.255.0 and .1 usable (no network/broadcast), saves 50% IPs for P2P links. Typical Cisco/Juniper MPLS WAN.

Example 4 - /28 web services DMZ Comcast. 73.181.50.16/28 (Comcast ISP US public). Network 73.181.50.16, broadcast 73.181.50.31. Host range 73.181.50.17 - .30 (14 usable). Typical small DMZ configuration: webserver, mailserver, VPN gateway. Cisco ASA firewall inside (RFC 1918) + outside (public DMZ) + dmz (servers).

Example 5 - university /16 VLSM subnetting. MIT 18.0.0.0/16 (65534 hosts, historical). VLSM subnetting: /20 schools (4094 hosts) for each macro-area, /24 departments (254 hosts), /27 labs (30 hosts), /30 inter-switch Ethernet trunks. Hierarchical allocation enables modular reassignment without global re-numbering. Cisco DNA Center automates in modern datacenters.

Limits and considerations

  1. IPv4 exhausted IANA 2011, regional RIRs 2011-2019: new sites must use IPv6 or NAT/CGNAT.
  2. RFC 1918 private NOT routable on public Internet: NAT mandatory for Internet access.
  3. NAT/PAT (RFC 3022) translates private to public addresses, breaking end-to-end principle (VoIP, P2P problem).
  4. CGNAT mobile carriers (Verizon, T-Mobile, AT&T): shared public IP 100.64.0.0/10 (RFC 6598), port forward, gaming issue.
  5. Multicast /4 224.0.0.0/4 (Class D): video streaming, IPTV, OSPF/EIGRP routing protocols.
  6. Loopback 127.0.0.0/8: localhost, not routable outside host.
  7. Link-local 169.254.0.0/16 (RFC 3927): IPv4 autoconfiguration when DHCP fails (Microsoft APIPA).
  8. Subnet zero (/25 first subnet) and all-ones historically forbidden, RFC 1812 re-enables on modern Cisco routers.
  9. VLSM requires router support (default Cisco IOS, Juniper, MikroTik); strict legacy Class-C no.
  10. IPv6 transition: dual-stack, 6to4, Teredo, NAT64 (RFC 6052) progressively.

Common errors

  1. Confusing network address with first host (e.g., 192.168.1.0 NO, .1 YES).
  2. Assigning broadcast to host (192.168.1.255 NO).
  3. Overlapping subnets (192.168.1.0/24 and 192.168.1.0/25 incompatible).
  4. Ignoring reserved gateway/loopback/multicast.
  5. Computing hosts with 2^n formula instead of 2^n - 2 (error /24 256 vs 254).
  6. Confusing subnet mask 255.255.255.0 with CIDR /24 (they are equivalent).
  7. Routing without summary: 200 /24 in table instead of 1 /16 aggregated.
  8. NAT with overlapping private classes LAN+VPN: routing loop, packet drop.
  9. IPv4 strictly classful: pre-1993 hinders subnetting, deprecated.
  10. Mixing IPv4 with IPv6 without dual-stack or appropriate tunneling.

Practical applications

  1. Sysadmin / NetAdmin: firewall, switch, router configuration, Cisco/MikroTik/Juniper.
  2. Security: ASA/FortiGate/PaloAlto firewall rules, VLAN segmentation ACLs.
  3. Cloud: AWS VPC subnets, GCP VPC, Azure VNet, Kubernetes pod CIDR.
  4. Datacenter: spine-leaf VXLAN BGP-EVPN, Ansible/Terraform automation.
  5. ISP: customer assignment, BGP advertisement, ARIN database.
  6. VPN: IPsec site-to-site, OpenVPN tunneling, SSL VPN client routing.
  7. Enterprise Wi-Fi: multi-VLAN SSID, captive portal, eduroam universities.
  8. IoT: dedicated MQTT sensor subnets, Zigbee, LoRaWAN gateways.
  9. Certifications: Cisco CCNA/CCNP/CCIE, Juniper JNCIA/JNCIP, CompTIA Network+.
  10. Compliance: GDPR Art 4(1) IP as personal data, NIST SP 800-37 cybersecurity.

Support

Questions: info@calcoi.com. Educational tool for networking. For professional applications consult RFC 4632 CIDR, RFC 1918 private addresses, RFC 6598 CGNAT, RFC 3021 /31 point-to-point, Tanenbaum-Wetherall "Computer Networks" 5th ed (Pearson 2013), Forouzan "Data Communications and Networking" 5th ed (McGraw-Hill 2017), Cisco Press CCNA/CCNP study guides.

Updated July 2026

Frequently Asked Questions

What does CIDR /24 notation mean?

CIDR (Classless Inter-Domain Routing, RFC 4632) uses /N where N is the number of network prefix bits. /24 means first 24 bits identify network, remaining 8 bits hosts. /24 = subnet mask 255.255.255.0 = 256 total addresses (2^8) = 254 usable hosts (256 - network - broadcast). Pre-1993 'classful' system used fixed /8 (Class A), /16 (Class B), /24 (Class C); CIDR introduces flexibility for efficient IPv4 use after exhaustion 2011.

Difference between subnet mask and wildcard mask?

Subnet mask (e.g., 255.255.255.0) has 1s in network bits and 0s in host bits. Wildcard (255.255.255.0 inverted = 0.0.0.255) has opposite. Subnet mask used for AND with IP to determine network address. Wildcard used in Cisco/Juniper ACLs (deny ip 192.168.1.0 0.0.0.255 = deny entire /24 LAN). OR between network and wildcard yields broadcast. Cisco IOS classic access-list uses wildcard, RFC 4632 recommends modern more readable CIDR /N.

How many hosts in /24, /28, /30 subnets?

/24 = 2^8 - 2 = 254 hosts (256 total addresses, minus network and broadcast). /28 = 2^4 - 2 = 14 hosts (16 total). /30 = 2^2 - 2 = 2 hosts (4 total, router-router). /31 (RFC 3021) exception: 2 hosts both assignable (no separate network/broadcast), optimizes P2P links. /32 = 1 host (loopback). General formula: hosts = 2^(32-N) - 2 for N <= 30; 2 for /31; 1 for /32. Calculators automate.

What are RFC 1918 private addresses?

RFC 1918 (1996, Rekhter et al, IETF) reserves three NOT-routable blocks on public Internet for internal/LAN use: 10.0.0.0/8 (private Class A, 16M IPs), 172.16.0.0/12 (16 private Class Bs, 1M IPs), 192.168.0.0/16 (256 private Class Cs, 65k IPs). Need NAT (Network Address Translation, RFC 3022) to translate to public ISP IP for Internet. Typical US home: Comcast/AT&T/Verizon ISP assigns 192.168.1.0/24 router private LAN, NAT to WAN.

Difference between /30 and /31 for router links?

/30 (subnet mask 255.255.255.252) historical standard for P2P: 4 total addresses, 2 usable (router A, router B), 2 non-assignable (network, broadcast). /31 (RFC 3021, 2000, Cisco IOS supported) optimization: 2 total addresses, both assignable (no separate network/broadcast). Saves 50% IPs for MPLS WAN with thousands P2P links. Example /31: 172.16.255.0/31 and 172.16.255.1 both routers. 'ip address' with 'no broadcast' Cisco config.

How to do VLSM Variable Length Subnet Mask?

VLSM allows subnets with different prefixes within same supernet, allocating IPs based on actual needs. Example /16 university: /20 large schools (4094 hosts), /23 departments (510 hosts), /24 classic LAN (254), /27 labs (30), /30 P2P trunks. Compared to FLSM (fixed /24 everywhere): VLSM avoids IP waste. Requires routers with OSPF/EIGRP/BGP advertising different subnets (Cisco IOS, MikroTik RouterOS, Juniper Junos). Pre-1993 classful no VLSM.

How to configure a Cisco router for /24?

Example Cisco IOS interface config: 'enable / configure terminal / interface gigabitEthernet 0/1 / ip address 192.168.1.1 255.255.255.0 / no shutdown / end / write memory'. Verify: 'show ip interface brief', 'show running-config interface gi0/1'. Static route: 'ip route 0.0.0.0 0.0.0.0 192.168.1.254' (ISP default gateway). DHCP server: 'ip dhcp pool LAN / network 192.168.1.0 255.255.255.0 / default-router 192.168.1.1 / dns-server 8.8.8.8'. CCNA exam topics.

Formula

network = IP AND subnet_mask
broadcast = network OR (NOT subnet_mask)
mask = 0xFFFFFFFF << (32 - prefix)
total = 2^(32 - prefix)
hosts = 2^(32 - prefix) - 2 (eccetto /31 e /32)
first = network + 1
last = broadcast - 1
RFC 1918: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
RFC 791 IP; RFC 4632 CIDR; RFC 1918 private; RFC 3021 /31 P2P; RFC 6598 CGN

Comments (0)

No comments yet. Be the first!