IPv4 Subnet Calculator

Free IP subnet calculator for IPv4. Enter an IP address with a CIDR prefix or subnet mask to get the network address, broadcast address, usable host range, wildcard mask and a full subnet breakdown.
Subnet mask / CIDR
  • /32 (255.255.255.255)
  • /31 (255.255.255.254)
  • /30 (255.255.255.252)
  • /29 (255.255.255.248)
  • /28 (255.255.255.240)
  • /27 (255.255.255.224)
  • /26 (255.255.255.192)
  • /25 (255.255.255.128)
  • /24 (255.255.255.0)
  • /23 (255.255.254.0)
  • /22 (255.255.252.0)
  • /21 (255.255.248.0)
  • /20 (255.255.240.0)
  • /19 (255.255.224.0)
  • /18 (255.255.192.0)
  • /17 (255.255.128.0)
  • /16 (255.255.0.0)
  • /15 (255.254.0.0)
  • /14 (255.252.0.0)
  • /13 (255.248.0.0)
  • /12 (255.240.0.0)
  • /11 (255.224.0.0)
  • /10 (255.192.0.0)
  • /9 (255.128.0.0)
  • /8 (255.0.0.0)
  • /7 (254.0.0.0)
  • /6 (252.0.0.0)
  • /5 (248.0.0.0)
  • /4 (240.0.0.0)
  • /3 (224.0.0.0)
  • /2 (192.0.0.0)
  • /1 (128.0.0.0)
  • /0 (0.0.0.0)
Paste CIDR notation straight into the box, or type an address and pick the mask. Everything is worked out in your browser, so no address you enter is ever sent to us.

Try:

How to Use the IPv4 Subnet Calculator

Four steps from an address to a full subnet breakdown. Nothing you type leaves your browser, so you can safely paste internal addressing.

1

Enter an IPv4 address

Type any address, such as 192.168.1.10. You can also paste CIDR notation (10.0.0.0/8) or an address followed by a dotted subnet mask (192.168.1.10 255.255.255.0). The calculator reads all three forms.

2

Pick the subnet mask or CIDR prefix

Choose a prefix from /0 to /32. Each option shows its dotted-decimal subnet mask, so you can select by either format. Pasting a prefix into the address box selects it for you.

3

Read the subnet breakdown

You get the network address, broadcast address, first and last usable host, total and usable host counts, wildcard mask, IP class, address type, the binary breakdown, the reverse DNS (PTR) name and zone, and the SPF ip4: mechanism for a public block.

4

Split the network into smaller subnets

Use "Divide into smaller subnets" to break the block into equal-size subnets and list every network, usable range and broadcast address. The subnet holding your address is highlighted.

What Is an IPv4 Subnet?

An IPv4 subnet is a contiguous block of IP addresses that share the same network prefix. Every IPv4 address is 32 bits long, written as four octets, for example 192.168.1.10. Subnetting divides those 32 bits into two parts: the network portion, which identifies the subnet, and the host portion, which identifies individual devices inside it.

Splitting a large network into smaller IPv4 subnets reduces broadcast traffic, keeps routing tables manageable, and lets you apply security rules such as firewall policies, ACLs and SPF records to precise address ranges instead of entire networks.

What is a subnet mask?

A subnet mask is a 32-bit value that marks which bits of an IPv4 address belong to the network. The network bits are set to 1 and the host bits to 0. For example, 255.255.255.0 is 24 ones followed by 8 zeros, so the first three octets identify the network and the last octet identifies hosts.

What is the subnet prefix length in IPv4?

The subnet prefix length is the number of 1-bits in the subnet mask, written after a slash in CIDR (Classless Inter-Domain Routing) notation. 192.168.1.0/24 means the first 24 bits are the network prefix, which is the same as the mask 255.255.255.0. IPv4 prefix lengths run from /0, the entire address space, to /32, a single host. Windows, macOS and most routers ask for either the prefix length or the dotted subnet mask, and this calculator converts between the two.

How to Calculate an IPv4 Subnet by Hand

You can work out any IPv4 subnet in four steps. Here is the math for 172.16.5.130/27, the same result the calculator above produces.

  1. Convert the prefix to a mask. /27 means 27 network bits, so the mask is 255.255.255.224. The last octet is 11100000 in binary, which equals 224.
  2. Find the block size. Subtract the interesting octet of the mask from 256: 256 - 224 = 32. Subnets in the last octet therefore start at 0, 32, 64, 96, 128, 160, 192 and 224.
  3. Find the network address. Take the largest multiple of 32 that is less than or equal to 130. That is 128, so the network address is 172.16.5.128.
  4. Find the broadcast address and host range. The next subnet starts at 160, so the broadcast is one below it: 172.16.5.159. Usable hosts run from .129 to .158.
Worked example: 172.16.5.130/27
IP address and prefix172.16.5.130/27
Subnet mask255.255.255.224
Wildcard mask0.0.0.31
Network address172.16.5.128
Broadcast address172.16.5.159
Usable host range172.16.5.129 - 172.16.5.158
Usable hosts2^5 - 2 = 30

Formula for usable hosts: 2^(32 - prefix) - 2. The two addresses you subtract are the network address, where every host bit is 0, and the broadcast address, where every host bit is 1. Two exceptions apply: a /31 has 2 usable addresses for point-to-point links (RFC 3021), and a /32 identifies a single host.

What Subnet Mask Do I Need for a Given Number of Hosts?

Find the smallest power of two that is at least your host count plus 2, then subtract its exponent from 32. For 40 devices: 40 + 2 = 42, the next power of two is 64, which is 2^6, so you need a /26 (255.255.255.192), giving 62 usable hosts.

IPv4 Subnet Mask Cheat Sheet (CIDR Chart)

Every IPv4 prefix length with its subnet mask, wildcard mask and host count. Choose any prefix to load it into the calculator.

IPv4 CIDR prefix lengths, /0 to /32
CIDRSubnet maskWildcard maskTotal addressesUsable hostsNotes
0.0.0.0255.255.255.2554,294,967,2964,294,967,294
128.0.0.0127.255.255.2552,147,483,6482,147,483,646
192.0.0.063.255.255.2551,073,741,8241,073,741,822
224.0.0.031.255.255.255536,870,912536,870,910
240.0.0.015.255.255.255268,435,456268,435,454
248.0.0.07.255.255.255134,217,728134,217,726
252.0.0.03.255.255.25567,108,86467,108,862
254.0.0.01.255.255.25533,554,43233,554,430
255.0.0.00.255.255.25516,777,21616,777,214Class A default
255.128.0.00.127.255.2558,388,6088,388,606
255.192.0.00.63.255.2554,194,3044,194,302
255.224.0.00.31.255.2552,097,1522,097,150
255.240.0.00.15.255.2551,048,5761,048,574172.16.0.0/12 private block
255.248.0.00.7.255.255524,288524,286
255.252.0.00.3.255.255262,144262,142
255.254.0.00.1.255.255131,072131,070
255.255.0.00.0.255.25565,53665,534Class B default
255.255.128.00.0.127.25532,76832,766
255.255.192.00.0.63.25516,38416,382
255.255.224.00.0.31.2558,1928,190
255.255.240.00.0.15.2554,0964,094
255.255.248.00.0.7.2552,0482,046
255.255.252.00.0.3.2551,0241,022Common cloud VPC subnet
255.255.254.00.0.1.255512510
255.255.255.00.0.0.255256254Class C default, typical LAN
255.255.255.1280.0.0.127128126
255.255.255.1920.0.0.636462
255.255.255.2240.0.0.313230
255.255.255.2400.0.0.151614Small office or DMZ
255.255.255.2480.0.0.786Common ISP static block
255.255.255.2520.0.0.342Legacy point-to-point link
255.255.255.2540.0.0.122Point-to-point (RFC 3021)
255.255.255.2550.0.0.011Single host

Private and Reserved IPv4 Address Ranges

The calculator labels each address by type. These are the ranges it recognizes, from the IANA IPv4 Special-Purpose Address Registry.

Special-purpose IPv4 blocks
RangePurposeStandard
10.0.0.0/8Private networkRFC 1918
172.16.0.0/12Private networkRFC 1918
192.168.0.0/16Private networkRFC 1918
100.64.0.0/10Carrier-grade NATRFC 6598
127.0.0.0/8LoopbackRFC 1122
169.254.0.0/16Link-local (APIPA)RFC 3927
198.18.0.0/15BenchmarkingRFC 2544
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24Documentation and examplesRFC 5737
224.0.0.0/4MulticastRFC 5771
240.0.0.0/4ReservedRFC 1112

How to Find Your IPv4 Subnet Mask

  • Windows: open Command Prompt and run ipconfig. Look for "Subnet Mask" under your active adapter.
  • macOS: open System Settings, then Network, your connection, Details, TCP/IP. In Terminal, ipconfig getoption en0 subnet_mask prints the same value.
  • Linux: run ip addr. The address appears in CIDR form, such as 192.168.1.23/24, and the number after the slash is the prefix length.

Paste the address and mask into the calculator to see the full subnet it belongs to.

IPv4 Subnets and Email Authentication

Subnetting is not only a network engineering task. If you send email, your SPF record lists the servers allowed to send on behalf of your domain, and it does that with ip4: mechanisms that accept CIDR ranges. ip4:203.0.113.0/24 authorizes all 256 addresses in that block.

A prefix that is too broad lets servers you do not control pass SPF for your domain. A prefix that is too narrow makes legitimate mail fail SPF, which then shows up as DMARC failures and, once you move to an enforcement policy, as rejected mail. For a public subnet the calculator shows the exact ip4: value to copy into your record, and the usable host range tells you precisely which addresses that mechanism covers. It warns about a block broader than a /16, and offers no value for private or reserved space or for anything broader than a /8.

Keep ip4 ranges tight
Authorize the smallest block that covers your real sending hosts. A /24 is 256 addresses; a /16 is 65,536. Every address you add is one more host that can pass SPF as your domain.
ip4 ranges cost no DNS lookups
SPF allows 10 DNS-querying mechanisms. An ip4: range is resolved from the record itself, so replacing an include: with the ranges behind it is one way to stay under the limit.
Private ranges do not belong in SPF
RFC 1918 addresses such as 10.0.0.0/8 never reach a receiving mail server, so an ip4: mechanism for them authorizes nothing and only adds noise to the record.

More Free Network and Email Security Tools

IPv4 Subnet Calculator FAQ

What is an IPv4 subnet calculator?
An IPv4 subnet calculator takes an IP address and a CIDR prefix or subnet mask and works out the subnet it belongs to: the network address, broadcast address, usable host range, number of hosts, subnet mask and wildcard mask. It saves you from doing the binary math by hand.
How do you calculate IPv4 subnets?
Convert the prefix to a subnet mask, find the block size (256 minus the mask value in the octet where the network bits end), round the IP down to the nearest multiple of the block size to get the network address, and subtract one from the next block to get the broadcast address. Every address in between is a usable host.
What does /24 mean in an IP address?
It is CIDR notation for the subnet prefix length. /24 means the first 24 bits identify the network, which equals the subnet mask 255.255.255.0. A /24 subnet contains 256 addresses, 254 of them usable by hosts.
How many hosts are in a /26 subnet?
A /26 has 2^(32-26) = 64 addresses. Subtracting the network and broadcast addresses leaves 62 usable hosts. The subnet mask is 255.255.255.192.
What subnet mask do I need for 50 hosts?
Add 2 for the network and broadcast addresses (52), then round up to the next power of two (64). That is a /26, or 255.255.255.192, giving 62 usable hosts.
What is a wildcard mask?
A wildcard mask is the inverse of the subnet mask, for example 0.0.0.255 for a /24. Cisco ACLs and OSPF configuration use wildcard masks to specify which bits of an address may vary.
Why does a /31 subnet have 2 usable addresses?
Normally the first and last addresses in a subnet are reserved for the network and broadcast addresses. RFC 3021 makes an exception for /31 point-to-point links, where there is no need for a broadcast address, so both addresses can be assigned to the two ends of the link.
Which IPv4 address ranges are private?
RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 for private networks. These addresses are not routed on the public internet. The calculator also flags loopback, link-local, carrier-grade NAT, multicast and documentation ranges.
How do I use a subnet in an SPF record?
Add it as an ip4 mechanism with the CIDR prefix, for example ip4:203.0.113.0/24. The calculator shows the exact ip4 value for a public subnet. Keep ranges as narrow as possible so only your real mail servers are authorized to send email for your domain.

Authorizing IP ranges in SPF?

Validate your SPF record and check every ip4 range and lookup with PowerDMARC.