OpenWrt Guide

Guides to OpenWrt router hardware compatibility and LuCI setup.

An independent, unofficial guide. Not affiliated with the OpenWrt project.

Illustration of an example router session. It assumes a br-lan bridge whose netmask is already 255.255.255.0 (/24), so only the address is set. The port lights show example cable links and do not follow the commands.

Guides

config guide 'first'

The first guides are being prepared.

Subnet calculator

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.

You can also type the address with its prefix, such as 10.0.0.1/8. The results update as you type and are hidden while the address is incomplete; a mistake is reported when you press Calculate or leave the field.

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).