taap.digitalnetwork engineering toolkit

IPv4 subnet calculator

Paste 10.20.30.40/22, 10.20.30.40 255.255.252.0 or a bare address plus a prefix. You get the subnet boundaries, the host range and the bitwise math behind them.

subnet4
Accepts 10.0.0.1/8, 10.0.0.1 255.0.0.0 or just the IP with the prefix below.

How the calculator derives a subnet

Every IPv4 subnet is defined by two 32-bit values: the address and the mask. The prefix length (/26) is just the count of leading 1-bits in the mask. The calculator runs three bitwise operations:

network = IP AND mask
broadcast = network OR (NOT mask)
usable hosts = 2(32 − prefix) − 2

The first and last host are simply network + 1 and broadcast − 1. Two edge cases follow the RFCs: a /31 has two usable addresses and no broadcast (RFC 3021, point-to-point links), and a /32 is a single host route, typical for loopbacks and router IDs.

Worked example: 192.168.1.130/26

A /26 leaves 6 host bits, so each block is 26 = 64 addresses and the mask is 255.255.255.192. Only the fourth octet is interesting:

130 = 10000010
192 = 11000000
AND = 10000000 = 128
FieldValue
Network192.168.1.128/26
First host192.168.1.129
Last host192.168.1.190
Broadcast192.168.1.191
Usable hosts62
Wildcard0.0.0.63

The fast mental method: block size = 256 − interesting mask octet (256 − 192 = 64). Subnets start at multiples of 64 (0, 64, 128, 192); 130 falls in the block that starts at 128.

Applying it on real gear

Once you have the values, the configuration is mechanical. Most platforms accept prefix notation; classic IOS still wants the dotted mask:

! Cisco IOS / IOS XE
interface GigabitEthernet0/1
 ip address 192.168.1.129 255.255.255.192

# Juniper Junos
set interfaces ge-0/0/1 unit 0 family inet address 192.168.1.129/26

# MikroTik RouterOS
/ip address add address=192.168.1.129/26 interface=ether2

# Linux iproute2
ip addr add 192.168.1.129/26 dev eth1

Design tips

  • Use the first usable address as the default gateway consistently across the site; it makes troubleshooting and documentation predictable.
  • Size user VLANs with 30–50% headroom. Renumbering a live subnet costs far more than a few wasted addresses in RFC 1918 space.
  • Keep 100.64.0.0/10 (RFC 6598, CGNAT) out of your internal plan if your ISP uses carrier-grade NAT; overlapping ranges break routing in subtle ways.
  • Align subnets on boundaries that summarize cleanly per site or per building, so a single route can represent each location (RFC 4632).

The neighbor table under the result lists the adjacent subnets of the same size inside the next shorter prefix, which helps you see where a block sits and what is free around it.

Frequently asked questions

Why are 2 addresses subtracted from the host count?

The all-zeros host value identifies the network and the all-ones value is the directed broadcast. Neither can be assigned to an interface, except on /31 (RFC 3021) and /32.

Can I use a /31 on a point-to-point link?

Yes. RFC 3021 allows /31 on point-to-point links: both addresses are usable and there is no broadcast. Cisco IOS, Junos, Arista EOS and Linux all support it, and it halves address consumption versus /30.

Does the calculator accept a dotted mask?

Yes. Enter 10.1.2.3 255.255.240.0 and it converts the mask to /20. Non-contiguous masks are rejected because they are not valid subnet masks.

What does the class field mean today?

Classful addressing (A/B/C) has been obsolete since CIDR (RFC 4632). It is shown for exam context only; routing and allocation use prefix length.

Study and design tool. Validate any configuration in a lab and against vendor documentation before applying it in production.