The /31 subnet

A /31 subnet uses the mask 255.255.255.254 and holds 2 addresses, 2 of them usable.

Reference data last reviewed:

/31
Prefix length
255.255.255.254
Subnet mask
0.0.0.1
Wildcard mask
2
Usable hosts

The /31 mask is 31 network bits followed by 1 host bits, for a total of 32 bits.

31 network bits (the 1s)1 host bit (the 0s)

The /31 special case: RFC 3021

A /31 has two addresses. Under the classic rule that would leave zero usable hosts, which is why /31 was long considered unusable and point-to-point links wasted a /30 on two hosts plus a network and a broadcast address.

RFC 3021 changed that for point-to-point links specifically. On such a link there can only ever be two ends, so there is no need for a broadcast address to reach the others: both addresses are assignable, and the block is written with no network or broadcast reservation at all.

This halves the address cost of every router-to-router link. It applies to point-to-point interfaces, not to shared media: a /31 on an Ethernet segment with three devices is still wrong.

A /31 covers two IPv4 addresses and, under RFC 3021, both are usable. The mask is 255.255.255.254, so it is the standard choice for point-to-point links where a full /30 would waste two addresses on network and broadcast.

On a /31 there is no separate broadcast address; the two hosts simply talk to each other. Router vendors have supported /31 links for years, and they halve the address cost of every point-to-point circuit.

Below you can see the exact network, broadcast, and host range for any /31 you enter, calculated instantly in your browser.

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, the 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
Size1/128 of a class C block

A note on the example: 192.0.2.0 is in 192.0.2.0/24, documentation (test-net-1) space under RFC 5737. Reserved for examples and documentation. Safe to print, never routed. Every example on this site uses reserved space on purpose, so nothing here points at somebody's real network.

Splitting a /31 into smaller subnets

Borrowing bits from the host part doubles the number of subnets and halves the size of each one. This is what a /31 looks like at the next 1 prefix length.

How a /31 block divides into longer prefixes
Split intoSubnetsMaskUsable hosts each
/322255.255.255.2551

Each subnet has to start on a multiple of its own size, which is what keeps the blocks from overlapping. Working the other way, from a host count back to a prefix, is what subnet by host count is for.

Do this from the terminal

The same numbers are available as keyless JSON, and there are good local tools that need no network at all. Naming them costs nothing and is more useful than pretending this page is the only option.

curl -s https://subnetkit.dev/api/cidr/31.json | jq

# or locally, with no network at all:
ipcalc 192.0.2.0/31
sipcalc 192.0.2.0/31

ipcalc ships in most Linux distributions and sipcalc handles IPv4 and IPv6. The SubnetKit API is the one to reach for in a build step or a script that wants the same values this page shows.

Frequently asked questions

What is the subnet mask for a /31?

A /31 uses the subnet mask 255.255.255.254. Its wildcard mask, used in access lists, is 0.0.0.1.

How many hosts are in a /31 subnet?

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

What is a /31 used for?

Point-to-point link (RFC 3021). It is equivalent to 1/128 of a class C block.

How do I calculate a /31 network?

Set the host bits to zero for the network address and to one for the broadcast address. The calculator on this page does it for any /31 block you enter.

How many /32 subnets fit in a /31?

2, each with 1 usable host and the mask 255.255.255.255. Every extra bit you borrow doubles the number of subnets and halves the size of each one.

Opening a port on a /31

A firewall rule needs two halves: the range and the port. The wildcard mask 0.0.0.1 matches this whole block in an access list. For the other half, the port number reference lists what each TCP and UDP port carries and whether it is encrypted by default, so you can tell what you are about to expose to 2 addresses.

Sources

The arithmetic on this page follows the documents below. Every number is computed from the prefix length rather than stored, and the calculation is covered by tests over all 33 prefixes.

Spotted something wrong? Tell us and it gets corrected. How the data is maintained is described on the about page.