Subnet Calculator
Calculate IPv4 subnets, network ranges, and CIDR notation
Quick Reference
| CIDR | Mask | Hosts |
|---|---|---|
| /8 | 255.0.0.0 | 16,777,214 |
| /16 | 255.255.0.0 | 65,534 |
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /27 | 255.255.255.224 | 30 |
| /28 | 255.255.255.240 | 14 |
| /29 | 255.255.255.248 | 6 |
| /30 | 255.255.255.252 | 2 |
| /31 | 255.255.255.254 | 2 (p2p) |
| /32 | 255.255.255.255 | 1 (host) |
About IPv4 Subnet Calculator
Our free IPv4 subnet calculator performs bit-accurate subnet calculations for any IP address and CIDR prefix length. Enter an IP address, select a subnet mask using the interactive CIDR slider or type a dotted-decimal mask, and instantly see the network address, broadcast address, usable host range, wildcard mask, IP class, and binary representations. This is an essential tool for network engineers, system administrators, and anyone working with IP addressing and subnetting.
The calculator uses JavaScript bitwise operators to perform precise binary AND, OR, and NOT operations on 32-bit IP addresses, ensuring mathematically correct results for every CIDR prefix from /0 to /32. All subnet math -- including network address derivation (IP AND mask), broadcast address computation (network OR NOT mask), and host count formulas -- is computed entirely in your browser with zero server communication.
Whether you are designing a corporate network, configuring firewall rules, studying for the CCNA or CompTIA Network+ certification, or simply need to determine how many usable hosts fit in a /27 subnet, this tool delivers instant, reliable answers with a clean visual layout including binary breakdowns and quick-select buttons for common subnet sizes.
Key Features
- Bit-Accurate Calculations: Uses native JavaScript bitwise operators with unsigned right shift (>>>0) for correct 32-bit unsigned arithmetic on every IP and mask value
- CIDR Slider: Interactive range slider from /0 to /32 that instantly updates the dotted-decimal subnet mask and all calculations
- Dotted Notation Input: Enter subnet masks in dotted-decimal format (e.g. 255.255.255.0) with automatic CIDR conversion and mask validation
- Quick-Select Buttons: One-click buttons for the most commonly used CIDR prefixes: /8, /16, /24, /25, /26, /27, and /28
- Complete Subnet Details: Network address, broadcast address, first and last usable hosts, total hosts, usable hosts, subnet mask, wildcard mask, and CIDR notation
- IP Class Detection: Automatically identifies the classful IP address class (A, B, C, D, or E) with corresponding address ranges
- Private/Public Detection: Determines whether the IP address falls within RFC 1918 private address space (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) or is publicly routable
- Binary Representations: Full binary breakdowns of IP address, subnet mask, network address, and broadcast address for educational and debugging purposes
- Edge Case Handling: Correct behavior for /31 (point-to-point links per RFC 3021) and /32 (single host) subnets
- Input Validation: Real-time validation of IP address format and subnet mask contiguity with clear error messages
How Subnetting Works
Subnetting is the process of dividing a larger IP network into smaller, more manageable sub-networks (subnets). Every IPv4 address is a 32-bit number divided into a network portion and a host portion. The subnet mask defines where this division occurs: bits set to 1 represent the network portion, and bits set to 0 represent the host portion.
- Network Address: Obtained by performing a bitwise AND between the IP address and subnet mask. This is the identifier for the subnet itself and cannot be assigned to a host.
- Broadcast Address: Obtained by performing a bitwise OR between the network address and the inverted subnet mask (wildcard mask). Packets sent to this address reach all hosts on the subnet.
- Usable Host Range: All addresses between network + 1 (first usable) and broadcast - 1 (last usable). For a /24 subnet this gives 254 usable addresses.
- Wildcard Mask: The bitwise NOT of the subnet mask. Used in access control lists (ACLs) on routers to specify which bits of an address should be matched.
- Host Count: For a prefix length of N, the total number of addresses is 2^(32-N). Usable hosts are total minus 2 (network and broadcast), except for /31 and /32 special cases.
Understanding CIDR Notation
CIDR (Classless Inter-Domain Routing) notation represents an IP address and its associated network prefix length in the format address/prefix. For example, 192.168.1.0/24 means the first 24 bits are the network portion, leaving 8 bits for host addresses (256 total addresses, 254 usable). CIDR replaced the older classful addressing system (Class A, B, C) to allow more flexible allocation of IP address space, reducing waste and slowing the exhaustion of the IPv4 address pool.
The prefix length directly corresponds to the number of contiguous 1-bits in the subnet mask. A /24 prefix equals a mask of 255.255.255.0 (24 ones followed by 8 zeros in binary). A /16 prefix equals 255.255.0.0, and a /8 prefix equals 255.0.0.0. Shorter prefixes create larger networks with more hosts; longer prefixes create smaller, more targeted subnets.
IP Address Classes
Although CIDR has largely replaced classful addressing, understanding IP classes remains important for certification exams, legacy network design, and default subnet mask assignments:
- Class A (0.0.0.0 - 127.255.255.255): First bit is 0. Default mask /8. Designed for very large networks with up to 16.7 million hosts per network. Private range: 10.0.0.0/8.
- Class B (128.0.0.0 - 191.255.255.255): First two bits are 10. Default mask /16. Supports up to 65,534 hosts per network. Private range: 172.16.0.0/12.
- Class C (192.0.0.0 - 223.255.255.255): First three bits are 110. Default mask /24. Supports up to 254 hosts per network. Private range: 192.168.0.0/16.
- Class D (224.0.0.0 - 239.255.255.255): First four bits are 1110. Reserved for multicast groups. Not used for standard host addressing.
- Class E (240.0.0.0 - 255.255.255.255): First four bits are 1111. Reserved for experimental and future use.
Use Cases
- Network Design: Plan IP address allocation for office buildings, data centers, and campus networks by determining the right subnet size for each VLAN or department.
- Firewall Configuration: Calculate network and wildcard masks needed for access control lists (ACLs) and firewall rules to permit or deny traffic to specific subnets.
- CCNA / CompTIA Study: Practice subnetting calculations for networking certification exams with instant binary verification of your manual work.
- Troubleshooting: Verify that two hosts are on the same subnet, check broadcast addresses, and confirm that routing table entries are correctly configured.
- Cloud Infrastructure: Design VPC subnets in AWS, Azure, or GCP by determining the right CIDR block sizes for public subnets, private subnets, and database tiers.
- Home Networking: Understand your home router's subnet configuration, determine how many devices can connect, and plan static IP assignments.
- Security Auditing: Identify whether IP addresses fall within private (RFC 1918) ranges or are publicly routable when reviewing network logs and security alerts.
- Documentation: Generate accurate subnet details for network documentation, IP address management (IPAM) records, and change management tickets.
Frequently Asked Questions
What is a subnet mask?
A subnet mask is a 32-bit number that divides an IP address into a network portion and a host portion. The mask consists of contiguous 1-bits (network part) followed by contiguous 0-bits (host part). For example, 255.255.255.0 in binary is 24 ones followed by 8 zeros, written as /24 in CIDR notation.
Why can I not use the network and broadcast addresses for hosts?
The network address (all host bits set to 0) identifies the subnet itself and is used in routing tables. The broadcast address (all host bits set to 1) is used to send packets to all hosts on the subnet simultaneously. Assigning either address to a host would cause routing and delivery conflicts.
What is a /31 subnet used for?
A /31 subnet (RFC 3021) is used for point-to-point links between two routers. Since point-to-point links only have two endpoints and do not need a network or broadcast address, both addresses in the /31 are usable, conserving IP address space on backbone links.
What is a wildcard mask?
A wildcard mask is the bitwise inverse of a subnet mask. For a /24 network (mask 255.255.255.0), the wildcard mask is 0.0.0.255. Wildcard masks are used in router ACLs and OSPF configurations to specify which bits of an IP address must match (0 bits) and which can vary (1 bits).
Is this calculator free and private?
Yes. This subnet calculator is completely free with no registration required. All calculations are performed entirely in your browser using client-side JavaScript. No IP addresses or network data are ever transmitted to any server.
What is the difference between private and public IP addresses?
Private IP addresses (defined in RFC 1918) are reserved for internal use within organizations and are not routable on the public internet. The three private ranges are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. Public IP addresses are globally unique and routable across the internet. Network Address Translation (NAT) allows devices with private addresses to access the internet through a public address.
Tips & Best Practices
- Right-size your subnets: Choose the smallest subnet that accommodates your current host count plus 20-30% growth. Over-allocating wastes address space; under-allocating forces painful re-addressing.
- Use the binary view for learning: Examining the binary representations of IP addresses and masks builds strong subnetting intuition and helps you solve problems faster on certification exams.
- Plan for VLANs: Align each VLAN with its own subnet. A common pattern is /24 for user VLANs, /28 or /29 for management networks, and /30 or /31 for router point-to-point links.
- Document everything: Record the network address, CIDR notation, usable range, gateway (typically first or last usable host), and purpose for every subnet in your IP address management system.
- Reserve addresses consistently: Adopt a standard convention such as using the first usable address as the default gateway and the last few addresses for infrastructure devices (DNS, DHCP servers).
- Use private addresses internally: Use RFC 1918 private address space for internal networks and NAT for internet access. This conserves public IP addresses and adds a layer of security.
Related Tools
CSS Specificity Calculator
Calculate and compare CSS selector specificity scores
Chmod Calculator
Calculate Linux file permissions in octal and symbolic
Savings Goal Calculator
Plan how much to save monthly to reach your financial goal
Heart Rate Zone Calculator
Calculate training heart rate zones for exercise
Liquidation Calculator
Calculate crypto leverage positions and liquidation prices
ROI Calculator
Calculate return on investment and annualized returns
Body Fat Calculator
Estimate body fat percentage using US Navy and BMI methods
Calorie Calculator
Calculate daily calorie needs based on goals and activity
Scientific Calculator
Advanced calculator with scientific functions
GPA Calculator
Calculate your Grade Point Average from course grades and credits
Water Intake Calculator
Calculate daily water intake needs based on weight
Electricity Cost Calculator
Calculate electricity costs for your appliances and devices
Last Added Free Tools
YouTube Thumbnail Downloader
Download any YouTube video thumbnail in HD and all other resolutions
YouTube Tag Extractor
Reveal the hidden tags of any YouTube video and copy them in one click
YouTube Channel ID Finder
Convert any handle or channel URL to the permanent channel ID with RSS feed
YouTube Subscriber Counter
Track any channel's subscriber count live with auto-refresh
YouTube Dislike Checker
See the hidden dislike count and like ratio of any YouTube video
YouTube Banner Maker
Design 2560x1440 channel art with safe-area guides and export as PNG
YouTube Revenue Calculator
Estimate YouTube earnings from views and RPM by niche
YouTube Watch Time Calculator
Calculate watch hours and track progress toward 4000 hours for monetization
YouTube Embed Code Generator
Generate responsive iframe embed code with start time, autoplay, and privacy mode
YouTube Timestamp Link Generator
Create YouTube links that start at an exact time
YouTube Subscribe Link Generator
Build channel links that open with a subscribe confirmation popup
YouTube Font Generator
Convert text into fancy Unicode fonts for titles, comments, and channel names