Subnet calculator
Planning a LAN, a guest network or a VLAN interface? Enter the router's address on that network and its prefix length. Every number below comes from binary arithmetic on what you type; the formula and its assumptions are under the results.
Type an IPv4 address and pick a prefix length. The calculator works out the network address, mask, block bounds and address counts with plain binary arithmetic, the kind of numbers you enter in LuCI or /etc/config/network. The first result shown is an example for 192.168.1.1/24.
Example estimate: 192.168.1.0/24 has 254 theoretical host slots.
- Network address
- 192.168.1.0/24
- Subnet mask
- 255.255.255.0
- Subnet-directed broadcast
- 192.168.1.255
- Host-position range
- 192.168.1.1 to 192.168.1.254
- Theoretical host slots
- 254
- Total addresses
- 256
- Address you typed
- A host position inside the block
First 24 bits are the network part (bold); the last 8 bits are the host part (dotted underline).
config interface 'lan' option proto 'static' list ipaddr '192.168.1.1/24'
Example only, in the form the OpenWrt 25.12 configuration generator writes: the address and prefix length as one CIDR list item in /etc/config/network. A real lan section has more options, such as its device, and your release may differ. See config_generate (OpenWrt 25.12 source) (OpenWrt project).
Formula and assumptions
p = prefix length, 0 to 32 h = 32 - p (host bits) total = 2^h (addresses in the block) mask = 32 bits, the first p set to 1 network = address AND mask top = network OR (NOT mask) (NOT works on 32 bits) ordinary subnets, /1 to /30 only: broadcast = top (subnet-directed broadcast) first host = network + 1 last host = broadcast - 1 host slots = 2^h - 2
- Results are an estimate for planning, worked out only from what you type. Check them against your router's own settings before you apply a change.
- For /1 to /30 the first address (network) and the last address (subnet-directed broadcast) are not host positions, so 2 is taken off the total. "Theoretical host slots" are positions in the block, not a promise that an address can be assigned.
- /0 is the default route and covers the whole IPv4 space, so no host range is shown.
- /31 is treated as a point-to-point link where both addresses can be used, as RFC 3021 describes. It has no subnet-directed broadcast address.
- /32 is a single address (a host route).
- On a LAN, the router's own address takes one of the host positions, so other devices can have at most one fewer.
- Each part of the address must be a whole number from 0 to 255. Whether an address is suitable or available (for example loopback or other special-use addresses, or one already in use) is not checked; see the IANA registry below.
Sources: RFC 4632: Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan, section 3.1 (IETF); RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links, sections 2.1, 2.2 and 3.3 (IETF); RFC 1812: Requirements for IP Version 4 Routers, sections 4.2.2.11 and 5.3.5 (IETF); IANA IPv4 Special-Purpose Address Registry (IANA).
For where these values go on a router, browse the guides.