CalcTrace

IPv4 Subnet Calculator

Enter an IPv4 address with a prefix length or a dotted subnet mask to get the network and broadcast addresses, the usable host range, the wildcard mask and a binary view. You can also split the network into equal smaller subnets.

Last updated .

Address and mask

Four numbers from 0 to 255. You can also type the prefix here, as in 192.168.1.130/26.

For example 26, /26 or 255.255.255.192.

Leave empty for no split. Each extra bit in the prefix doubles the number of subnets and halves their size.

Result

Network

–

–Usable hosts
–Total addresses
–Prefix length
–Address type
Show the working

    How subnetting works

    An IPv4 address is a 32-bit number, written as four 8-bit numbers (octets) from 0 to 255. A subnet divides those 32 bits in two. The first bits identify the network and are the same for every device on it. The remaining bits identify one host within the network. The prefix length, written after a slash, says how many bits belong to the network part.

    A subnet mask is the same information in dotted form: a one for every network bit and a zero for every host bit. A /26 is 26 ones followed by 6 zeros, which reads as 255.255.255.192. Because the ones must be continuous, only 33 masks are valid, one for each prefix from /0 to /32.

    Network address = address AND mask

    Wildcard mask = NOT mask

    Broadcast address = network address OR wildcard mask

    Total addresses = 2(32 − p)  and  usable hosts = 2(32 − p) − 2

    Here p is the prefix length. AND, OR and NOT are bitwise operations, applied to each of the 32 bits separately: AND keeps a bit only where the mask has a one, which clears the host bits; OR with the wildcard mask sets every host bit to one. Two addresses are subtracted from the host count because the first address in the block names the network itself and the last is the broadcast address, which reaches every host on the subnet. Usable hosts run from the network address plus one to the broadcast address minus one.

    Worked example: 192.168.1.130/26

    1. Write the mask. 26 bits is three full octets (24 bits) plus 2 bits of the fourth. Two leading ones in an octet are 11000000, which is 128 + 64 = 192. The mask is 255.255.255.192.
    2. Find the block size. 32 − 26 = 6 host bits, and 26 = 64 addresses in each subnet. A quick way to get the same figure is 256 − 192 = 64.
    3. Find the block that contains the address. In the fourth octet, blocks of 64 start at 0, 64, 128 and 192. The address ends in 130, which falls in the block starting at 128. In binary, 130 is 10000010, and 10000010 AND 11000000 = 10000000, which is 128. The network address is 192.168.1.128.
    4. Find the broadcast address. It is the last address of the block: 128 + 64 − 1 = 191, so 192.168.1.191.
    5. Count the hosts. 64 − 2 = 62 usable hosts, from 192.168.1.129 to 192.168.1.190.
    6. Write the wildcard mask. Subtract each octet of the mask from 255: 0.0.0.63.

    How /31 and /32 are handled

    The “minus two” rule breaks down for the two longest prefixes, and calculators differ in what they show. This one follows current practice.

    /31. A /31 contains 2 addresses. Taking away a network and a broadcast address would leave none, so RFC 3021 allows both to be used as host addresses on a point-to-point link between two routers. The calculator reports 2 usable hosts, lists both addresses as the host range and shows no broadcast address.

    /32. A /32 is a single address with no host bits. It is used for loopback interfaces and for routes to one specific host. The calculator reports 1 address, which is both the first and the last host, and no broadcast address.

    Private, loopback and link-local ranges

    The calculator checks the address you enter against the special-purpose ranges below and reports “Public” for anything else.

    RangeAddressesUse
    10.0.0.0/810.0.0.0 to 10.255.255.255Private (RFC 1918)
    172.16.0.0/12172.16.0.0 to 172.31.255.255Private (RFC 1918)
    192.168.0.0/16192.168.0.0 to 192.168.255.255Private (RFC 1918)
    127.0.0.0/8127.0.0.0 to 127.255.255.255Loopback: the device itself
    169.254.0.0/16169.254.0.0 to 169.254.255.255Link-local: self-assigned when no DHCP server answers
    100.64.0.0/10100.64.0.0 to 100.127.255.255Shared address space for carrier-grade NAT (RFC 6598)

    It also recognises multicast (224.0.0.0/4), the reserved block 240.0.0.0/4, the three documentation ranges 192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24, the benchmarking range 198.18.0.0/15 and addresses beginning with 0. Private addresses are not routed on the public internet, so they can be reused inside any organisation.

    Practical points

    The 172 range is the one people get wrong. Only 172.16 to 172.31 is private. An address such as 172.32.0.1 is public.

    Know the common sizes. A /24 has 256 addresses and 254 hosts. Each bit added halves it: /25 has 126 hosts, /26 has 62, /27 has 30, /28 has 14, /29 has 6 and /30 has 2. Going the other way, a /16 has 65,534 hosts and a /8 has 16,777,214.

    Splitting costs addresses. Dividing 192.168.1.0/24 into four /26 subnets gives networks at .0, .64, .128 and .192 with 62 hosts each. That is 248 usable addresses instead of 254, because every subnet needs its own network and broadcast address. Use the split box above to list the subnets for any prefix.

    Size for growth and for the gateway. The router’s interface takes one of the usable addresses, and some cloud platforms reserve several more in every subnet. Check the platform’s documentation before choosing a prefix that only just fits.

    Wildcard masks are not subnet masks. Access control lists and some routing protocols on network equipment expect the wildcard form, where a zero bit means “must match”. Entering 255.255.255.192 where 0.0.0.63 is expected matches the wrong addresses.