Subnet for 2 hosts

A network that needs 2 hosts fits in a /31, mask 255.255.255.254, with 2 usable addresses.

2
Hosts needed
/31
Smallest fitting prefix
255.255.255.254
Subnet mask
2
Usable hosts

A network built for 2 hosts is the classic point-to-point case. The smallest block that fits is a /31 (mask 255.255.255.254), which under RFC 3021 counts both of its addresses as usable hosts, with no network or broadcast address reserved.

If the router or firewall on the link does not support RFC 3021, use a /30 instead. It also covers 2 hosts, at the cost of two addresses spent on the network and broadcast.

Enter any address below to see the exact network, broadcast, and host range for a /31 block.

Calculate a /31 network

Accepts CIDR (192.0.2.0/24), IP + mask (192.0.2.0 255.255.255.0), or a bare IP (defaults to /24).

Network address192.0.2.0
Usable host range192.0.2.0 - 192.0.2.1
Broadcast address192.0.2.1
Usable hosts2
Subnet mask255.255.255.254
Wildcard mask0.0.0.1
CIDR notation192.0.2.0/31
Total addresses2
IP (binary)11000000.00000000.00000010.00000000
Mask (binary)11111111.11111111.11111111.11111110
Try:

Example: 192.0.2.0/31

Taking 192.0.2.0/31 as a worked example, a /31 block breaks down like this:

Network address192.0.2.0
Usable range192.0.2.0 - 192.0.2.1
Broadcast address192.0.2.1
Total addresses2
Usable hosts2

Frequently asked questions

What subnet mask do I need for 2 hosts?

A network with 2 hosts fits in a /31, which uses the mask 255.255.255.254 and provides 2 usable addresses.

How many addresses does a /31 block have in total?

A /31 has 2 total addresses, 2 of them usable (the total minus the network and broadcast addresses, except for /31 and /32).

Why does a 2-host network get a /31 instead of a /30?

Under RFC 3021, a /31 has no room for a separate network or broadcast address, so both of its addresses count as usable hosts. A /30 also works and is the more widely supported classic choice, but it spends two of its four addresses on the network and broadcast.

How do I work this out myself?

Find the smallest power of two, minus two, that is at least 2. That takes 1 host bits, which leaves a /31 prefix. See how to calculate a subnet mask for the full method.