taap.digitalnetwork engineering toolkit

What subnet mask do I need for 2 hosts?

Answer
/31 255.255.255.254 · 2 usable

For 2 hosts the smallest subnet is a /31 (255.255.255.254): 2 usable addresses with 0 spare. If you expect growth, a /30 gives 2 hosts.

hosts2mask · adjust the values
Pole with tangled wires against a clear sky
Pole with tangled wires against a clear sky. Photo: Wood Hong / Unsplash

Options for 2 hosts

PrefixMaskUsable hostsSpare
/31255.255.255.25420
/30255.255.255.25220
/29255.255.255.24864

Rule: find the power of 2 that, minus 2, covers the host count. The exponent is the number of host bits and the prefix is 32 minus those bits.

Step by step

  1. With 2 hosts there is no need for network and broadcast addresses: a point-to-point link can use a /31 (RFC 3021), with 2 addresses.
  2. Prefix: 32 − 1 = /31 (255.255.255.254).
  3. If the device does not accept /31, use a /30: 4 addresses, 2 usable.

Other host counts

HostsPrefixUsableUsed
2/312100%
6/296100%
10/281471%
14/2814100%
20/273067%
30/2730100%
50/266281%
60/266297%
100/2512679%
120/2512695%
200/2425479%
250/2425498%
500/2351098%
1,000/221,02298%
2,000/212,04698%
4,000/204,09498%

In practice

If the link may gain more devices later, a /29 gives 6 usable hosts and, with 2 hosts, sits at 33% used.

To try other values, open the Hosts → mask calculator with these numbers already filled in.

More questions like this

Frequently asked questions

Should I leave headroom?

Yes. Keep at least 20–30% for growth, printers, cameras and network gear; renumbering later costs more.

Why subtract 2 hosts?

The first address identifies the network and the last is the broadcast; neither can be assigned to a device. On /31 links (RFC 3021) both are used.