Subnet for 2 hosts
A network that needs 2 hosts fits in a /31, mask 255.255.255.254, with 2 usable addresses.
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).
11000000.00000000.00000010.0000000011111111.11111111.11111111.11111110Example: 192.0.2.0/31
Taking 192.0.2.0/31 as a worked example, a /31 block breaks down like this:
| Network address | 192.0.2.0 |
|---|---|
| Usable range | 192.0.2.0 - 192.0.2.1 |
| Broadcast address | 192.0.2.1 |
| Total addresses | 2 |
| Usable hosts | 2 |
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.