IPv4 subnet calculator
Network address, mask, broadcast address and host count from CIDR notation.
Fill in the fields and the result will appear here automatically.
Breaks an IPv4 network down from an address and a prefix length. All the arithmetic is bitwise: the address is a 32-bit number, the mask is a run of ones on the left, and the network address is their bitwise AND. That is exactly why a subnet boundary can fall inside an octet: a /20 prefix gives a mask of 255.255.240.0, which is not a network you work out in your head. Three cases are handled separately because the familiar «two to the power minus two» is wrong for them: /32 is a single host address, /31 is a two-address point-to-point link with no broadcast, and only from /30 down are the network and broadcast addresses subtracted.
How it works
Formula and logic
Four decimal octets from 0 to 255 form a 32-bit address. Integer prefix p from 0 to 32 supplies p leading mask bits; bitwise AND gives the network. For p≤30, the count excluding the two endpoints is 2^(32−p)−2. /31 shows two addresses under RFC3021 point-to-point semantics without a separate directed broadcast; /32 shows one address. These are CIDR boundaries, not permission to assign an address.
Example
Address 192.168.1.10 with a /24 prefix belongs to 192.168.1.0 with mask 255.255.255.0 and 254 hosts.
Fields and units
- IPv4 address — unitless
- Prefix length, bits — bits
How to use
- — Enter any address from the network — it need not be the network address itself.
- — Enter the prefix length: the number after the slash in CIDR notation.
- — Read the first and last host — that is the range available for assignment.
- — The wildcard mask is handy for access lists on Cisco equipment.
Method and limitations
- Calculation method
- Formula and logic
- Data or methodology source
- RFC3021: /31 on point-to-point links
- Limitation
- IPv4/CIDR arithmetic only. Special-use blocks, routing, DHCP and host presence are not checked. /31 semantics require a supported point-to-point link; limited broadcast 255.255.255.255 is not removed.
FAQ
Must I enter the network address itself?
No, any address from the network works. The calculator drops the low bits according to the mask and finds the network address itself.
Why does /20 give 255.255.240.0?
Because a subnet boundary need not align with an octet boundary. Twenty mask bits end halfway through the third octet, which yields 240.
How many hosts are in a /31?
Two, and both are usable. It is a point-to-point link under RFC 3021: no network or broadcast address is set aside.
And in a /32?
A single address. That prefix designates one specific host, for example a route to a single server.
Is IPv6 supported?
No, IPv4 only. IPv6 addressing works differently, and mixing them in one calculation would conflate two different models.