Free tool

Subnet calculator for IPv4 and IPv6

Type an IP address with a prefix or mask, like 192.168.1.10/24 or 2001:db8::/48, to get the network and broadcast address, the usable host range, the subnet and wildcard mask and the host count. Then split the block into subnets, plan a VLSM layout, merge a list of routes, check which IPs it contains, or paste a range to get its CIDR blocks.

Free · no sign-up · runs in your browser, nothing is uploaded

Sample:

192.168.1.10 is a host inside .

Network

192.168.1.0/24

Usable hosts

254

Subnet mask

255.255.255.0

Type

Private (RFC 1918)

Subnet details
Network address
192.168.1.0
Broadcast address
192.168.1.255
First usable host
192.168.1.1
Last usable host
192.168.1.254
Usable hostsTotal minus the network and broadcast addresses.
254
Total addresses
256
Subnet mask
255.255.255.0
Wildcard mask (ACLs, OSPF)
0.0.0.255
CIDR notation
192.168.1.0/24
Address range
192.168.1.0 - 192.168.1.255
Address info
Address type
Private (RFC 1918)
Class (legacy)
C
Integer
3232235786
Hex
0xC0A8010A
Mask in hex
0xFFFFFF00
IPv4-mapped IPv6
::ffff:192.168.1.10
Reverse DNS (PTR) name
10.1.168.192.in-addr.arpa
Reverse DNS zone
1.168.192.in-addr.arpa

Usable IPs if this is a cloud subnet

AWS VPC

251

−5 reserved

Azure VNet

251

−5 reserved

Google Cloud

252

−4 reserved

Binary
11000000101010000000000100001010

24 network bits · 8 host bits

mask 11111111.11111111.11111111.00000000

4 subnets of /26 (255.255.255.192), 62 usable each

SubnetHost rangeBroadcastUsable
192.168.1.0/26192.168.1.1 - 192.168.1.62192.168.1.6362
192.168.1.64/26192.168.1.65 - 192.168.1.126192.168.1.12762
192.168.1.128/26192.168.1.129 - 192.168.1.190192.168.1.19162
192.168.1.192/26192.168.1.193 - 192.168.1.254192.168.1.25562

How to calculate a subnet by hand

An IPv4 address is 32 bits. The prefix length (the number after the slash) says how many of those bits, from the left, name the network. The rest name a host inside it. Everything else follows from that split. Take 192.168.1.77/26:

Address    192.168.1.77    11000000.10101000.00000001.01 001101
Mask /26   255.255.255.192 11111111.11111111.11111111.11 000000
                                                     network | host

Network    = address AND mask           -> 192.168.1.64
Broadcast  = network with host bits = 1 -> 192.168.1.127
Hosts      = 2^(32-26) - 2 = 64 - 2     -> 62  (192.168.1.65 to .126)
Wildcard   = NOT mask                   -> 0.0.0.63

A shortcut for masks that end inside one octet: subtract that octet from 256 to get the block size. For /26 the last octet of the mask is 192, so blocks are 64 apart (.0, .64, .128, .192), and .77 falls in the block that starts at .64. IPv6 works the same way with 128 bits, written in hex, and without a broadcast address.

CIDR to subnet mask chart (/32 to /0)

Every IPv4 prefix length with its mask, wildcard mask and size. Usable hosts are the total minus the network and broadcast addresses, except /31 and /32. The binary converter shows how each mask octet looks in bits.

CIDRSubnet maskWildcardAddressesUsable hosts
/32255.255.255.2550.0.0.011
/31255.255.255.2540.0.0.122
/30255.255.255.2520.0.0.342
/29255.255.255.2480.0.0.786
/28255.255.255.2400.0.0.151614
/27255.255.255.2240.0.0.313230
/26255.255.255.1920.0.0.636462
/25255.255.255.1280.0.0.127128126
/24255.255.255.00.0.0.255256254
/23255.255.254.00.0.1.255512510
/22255.255.252.00.0.3.2551,0241,022
/21255.255.248.00.0.7.2552,0482,046
/20255.255.240.00.0.15.2554,0964,094
/19255.255.224.00.0.31.2558,1928,190
/18255.255.192.00.0.63.25516,38416,382
/17255.255.128.00.0.127.25532,76832,766
/16255.255.0.00.0.255.25565,53665,534
/15255.254.0.00.1.255.255131,072131,070
/14255.252.0.00.3.255.255262,144262,142
/13255.248.0.00.7.255.255524,288524,286
/12255.240.0.00.15.255.2551,048,5761,048,574
/11255.224.0.00.31.255.2552,097,1522,097,150
/10255.192.0.00.63.255.2554,194,3044,194,302
/9255.128.0.00.127.255.2558,388,6088,388,606
/8255.0.0.00.255.255.25516,777,21616,777,214
/7254.0.0.01.255.255.25533,554,43233,554,430
/6252.0.0.03.255.255.25567,108,86467,108,862
/5248.0.0.07.255.255.255134,217,728134,217,726
/4240.0.0.015.255.255.255268,435,456268,435,454
/3224.0.0.031.255.255.255536,870,912536,870,910
/2192.0.0.063.255.255.2551,073,741,8241,073,741,822
/1128.0.0.0127.255.255.2552,147,483,6482,147,483,646
/00.0.0.0255.255.255.2554,294,967,2964,294,967,294

IPv6 prefix sizes

IPv6 subnets are almost always /64, because SLAAC (stateless address autoconfiguration) needs a 64-bit interface ID. Larger prefixes are handed out to sites and customers. There is no broadcast address; the first address of a subnet is the subnet-router anycast address.

Prefix/64 subnets insideTypical use
/324,294,967,296Allocation to an ISP or large network
/4865,536A site or organization
/56256A home or small business from an ISP
/641One LAN or VLAN (needed for SLAAC)
/127n/a (2 addresses)Point-to-point router links (RFC 6164)
/128n/a (1 address)A single host or loopback

The calculator writes IPv6 the way RFC 5952 asks: lowercase, no leading zeros, and the longest run of zero groups shortened to ::. It also shows the fully expanded form and the ip6.arpa name you need for reverse DNS.

Private and reserved IP ranges

The address type shown in the tool comes from the IANA special-purpose registries. The ranges you meet most:

RangeWhat it isDefined in
10.0.0.0/8Private networkRFC 1918
172.16.0.0/12Private network (172.16.0.0 to 172.31.255.255)RFC 1918
192.168.0.0/16Private networkRFC 1918
100.64.0.0/10Shared address space for carrier-grade NATRFC 6598
127.0.0.0/8LoopbackRFC 1122
169.254.0.0/16Link-local, self-assigned when DHCP failsRFC 3927
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24Documentation examples (TEST-NET-1/2/3)RFC 5737
224.0.0.0/4MulticastRFC 5771
fc00::/7IPv6 unique local (private)RFC 4193
fe80::/10IPv6 link-localRFC 4291
2001:db8::/32IPv6 documentationRFC 3849

Cloud subnets have fewer usable IPs

Cloud providers keep a few addresses in every subnet for their own routers and DNS, so a /24 there gives you fewer than 254 hosts. The tool shows all three counts for any IPv4 subnet.

ProviderReserved per subnetUsable in a /24
AWS VPCFirst four and the last address. Subnets must be /16 to /28.251
Azure VNetFirst four and the last address. Subnets must be /2 to /29.251
Google Cloud VPCNetwork, gateway, second-to-last and broadcast address of the primary range. Subnets must be /4 to /29.252

When you plan a VPC, size each subnet for the hosts you need plus these reserved addresses, and leave room to grow. The VLSM planner above packs subnets largest first so they never overlap. Running infrastructure as code? Browse DevOps tools on DevHunt, or turn a container command into a compose file with the docker run to compose converter.

Subnet math in code

Most languages ship this in the standard library, so you rarely need to write the bit math yourself.

# Python
import ipaddress
net = ipaddress.ip_network("192.168.1.77/26", strict=False)
net.network_address, net.broadcast_address   # 192.168.1.64, 192.168.1.127
net.netmask, net.hostmask, net.num_addresses # 255.255.255.192, 0.0.0.63, 64
list(net.subnets(new_prefix=28))             # split into four /28s
ipaddress.ip_address("192.168.1.100") in net # True
list(ipaddress.summarize_address_range(
    ipaddress.ip_address("10.0.0.5"), ipaddress.ip_address("10.0.0.100")))  # range to CIDR

// Go (net/netip)
p := netip.MustParsePrefix("192.168.1.77/26")
p.Masked()                                   // 192.168.1.64/26
p.Contains(netip.MustParseAddr("192.168.1.100")) // true

-- PostgreSQL
SELECT network('192.168.1.77/26'::inet),    -- 192.168.1.64/26
       broadcast('192.168.1.77/26'::inet),  -- 192.168.1.127/26
       netmask('192.168.1.77/26'::inet),    -- 255.255.255.192
       '192.168.1.100'::inet << '192.168.1.64/26'::cidr;  -- true

// JavaScript (no built-in, IPv4 only)
const toInt = ip => ip.split('.').reduce((n, o) => (n << 8) + +o, 0) >>> 0;
const mask = prefix => (prefix ? (~0 << (32 - prefix)) >>> 0 : 0);
const network = (toInt('192.168.1.77') & mask(26)) >>> 0;

In JavaScript, remember >>> 0: bitwise operators work on signed 32-bit integers, so without it any address above 127.255.255.255 comes out negative. For IPv6, use BigInt, which is what this calculator does. To read the hex form of an address as a number, try the hex to decimal converter.

FAQ

What is the subnet mask for a /24?+

255.255.255.0. A /24 has 24 network bits and 8 host bits, so it holds 256 addresses. The first (.0) is the network address and the last (.255) is the broadcast address, which leaves 254 usable hosts.

How many IP addresses are in a /20?+

A /20 has 32 - 20 = 12 host bits, so it holds 2^12 = 4,096 addresses, of which 4,094 are usable hosts. The mask is 255.255.240.0. In general an IPv4 /n holds 2^(32 - n) addresses.

How do I calculate the CIDR range of a subnet?+

Convert the address and mask to binary and AND them: that gives the network address, the start of the range. Then set every host bit to 1 to get the last address. For 10.1.5.77/22 the network is 10.1.4.0 and the last address is 10.1.7.255. The calculator above does this for any IPv4 or IPv6 prefix.

What is the difference between a subnet mask and a wildcard mask?+

A wildcard mask is the subnet mask with every bit flipped. 255.255.255.0 becomes 0.0.0.255. Cisco ACLs and OSPF network statements use wildcard masks, where a 0 bit means "must match" and a 1 bit means "any value". If you paste a wildcard mask where a subnet mask belongs, the calculator tells you and shows the subnet mask.

Why does a subnet have two fewer usable hosts?+

In IPv4 the all-zeros host address names the network itself and the all-ones host address is the broadcast address, so neither can be given to a device. Two exceptions: a /31 has no network or broadcast address and both IPs are usable on point-to-point links (RFC 3021), and a /32 is a single host. IPv6 has no broadcast at all.

What are the IP address classes?+

Before CIDR (1993), the first bits of an IPv4 address set its class. Class A is 0-127 with a default /8, class B is 128-191 with /16, class C is 192-223 with /24, class D (224-239) is multicast and class E (240-255) is reserved. Routing has been classless since RFC 1519, so the class is only a label today.

How do I summarize a list of subnets into one route?+

Sort the blocks, merge any that overlap or touch, then cover each merged range with the fewest aligned CIDR blocks. 10.0.0.0/24 and 10.0.1.0/24 become 10.0.0.0/23, but 10.0.1.0/24 and 10.0.2.0/24 cannot merge, because 10.0.1.0 is not on a /23 boundary. Paste the list into "Summarize routes" above to get the exact result.

How do I find my own subnet mask?+

On Windows run ipconfig and read the Subnet Mask line. On macOS and Linux run ip addr (or ifconfig): the address is shown with a prefix such as 192.168.1.20/24, where /24 means 255.255.255.0. Paste that into the calculator to see the full network.

Sources: RFC 4632 (CIDR) · RFC 1918 (private IPv4) · RFC 6598 (shared address space) · RFC 3021 (/31 links) · RFC 5737 (IPv4 documentation) · RFC 4291 (IPv6 addressing) · RFC 5952 (IPv6 text format) · RFC 3056 (6to4) · RFC 4193 (IPv6 unique local) · IANA IPv4 special-purpose registry · IANA IPv6 special-purpose registry · AWS: subnet CIDR blocks · Azure: virtual network FAQ · Google Cloud: subnets · Python ipaddress · Go net/netip · PostgreSQL network functions. Checked 2026-10-31.