tip
~/geeksubnet/masks/31

/31 subnet mask: 255.255.255.254

Every value on this page is reproducible in the calculator.

The /31 prefix means the first 31 bits of the address identify the network and the remaining 1 identify the host. Written out, the mask is 255.255.255.254, in binary 11111111.11111111.11111111.11111110, and its Cisco wildcard or inverse form is 0.0.0.1. It covers 2 addresses, of which 2 can be given to hosts.

/31 at a glance

CIDR prefix/31
Subnet mask255.255.255.254
Mask in binary11111111.11111111.11111111.11111110
Wildcard (inverse) mask0.0.0.1
Host bits1
Total addresses2
Usable hosts2
Block size (magic number)2 in octet 4

Every /31 inside 192.168.1.0/24

A 192.168.1.0/24 contains 128 subnets of /31. Here are the first 8, which is enough to see the pattern: each one starts 2 after the last in octet 4.

NetworkFirst hostLast hostBroadcast
192.168.1.0/31192.168.1.0192.168.1.1n/a
192.168.1.2/31192.168.1.2192.168.1.3n/a
192.168.1.4/31192.168.1.4192.168.1.5n/a
192.168.1.6/31192.168.1.6192.168.1.7n/a
192.168.1.8/31192.168.1.8192.168.1.9n/a
192.168.1.10/31192.168.1.10192.168.1.11n/a
192.168.1.12/31192.168.1.12192.168.1.13n/a
192.168.1.14/31192.168.1.14192.168.1.15n/a

The magic number for /31

Take the interesting octet of the mask, the one that is neither 255 nor 0. For /31 that is 254 in octet 4. Subtract it from 256:

256 - 254 = 2

That is the block size. Every /31 network address is a multiple of 2 in octet 4, so you can list them by counting: 0, 2, 4, 6, and so on. No binary needed once you know the number.

Where a /31 shows up in practice

A /31 is the modern fix for point-to-point links. RFC 3021 says that on a link with exactly two devices you can drop the network and broadcast addresses entirely and use both addresses as hosts, halving the waste of a /30.

Frequently asked questions

How many hosts are in a /31?

A /31 holds 2 addresses and RFC 3021 allows both to be used as hosts on a point-to-point link, so the answer is 2.

What is the subnet mask for /31?

The /31 subnet mask is 255.255.255.254 in dotted-decimal notation.

What is the wildcard mask for /31?

The wildcard mask, also called the inverse mask, is 0.0.0.1. It is the bitwise inverse of 255.255.255.254 and is what Cisco access lists and OSPF network statements expect.

What is /31 in binary?

The /31 mask written out bit by bit is 11111111.11111111.11111111.11111110: 31 ones followed by 1 zeros.

How many /31 subnets fit in a /24?

A /24 splits into 128 subnets of /31.

Neighbouring masks: /30 is one bit shorter and holds twice as many addresses. /32 is one bit longer and holds half as many.
full cheat sheet subnetting basics open the calculator