Assigning a 31-Bit Subnet Mask to an IPv4 Address

To conserve address space, you can assign a 31-bit subnet mask to an IPv4 address.

You can configure an IPv4 address with a 31-bit subnet mask on any interface (for example, Ethernet, loopback, VE, or tunnel interfaces).

You cannot configure a secondary IPv4 address with a 31-bit subnet mask on any interface. The following error message is displayed when a secondary IPv4 address with a 31-bit subnet mask is configured: Error: Cannot assign /31 subnet address as secondary.

  1. Enter global configuration mode.
    device# configure terminal
  2. Enter interface configuration mode.
    device(config)# interface ethernet 1/1/5
  3. Configure an IP address with a 31-bit subnet mask.
    device(config-if-e1000-1/1/5)# ip address 10.9.9.9 255.255.255.254
    Using CIDR format, the IP address is 10.9.9.9/31.
  4. Return to privileged EXEC mode.
    device(config-if-e1000-1/1/5)# end
  5. To see when a 31-bit subnet mask is used, use the show ip route command.
    device# show ip route
    
    Total number of IP routes: 2
    Type Codes - B:BGP D:Connected O:OSPF R:RIP S:Static; Cost - Dist/Metric
    BGP  Codes - i:iBGP e:eBGP
    OSPF Codes - i:Inter Area 1:External Type 1 2:External Type 2
            Destination        Gateway         Port          Cost          Type Uptime
    1       10.9.9.8/31        DIRECT          e 1/1/5       0/0           D    1m53s 
    2       10.9.9.10/31       DIRECT          e 1/1/6       0/0           D    1m54s 
    

The following example assigns a 31-bit subnet mask to an IP address. This example uses CIDR notation for the IP address and subnet mask.

device# configure terminal
device(config)# interface ethernet 1/1/5
device(config)# ip address 10.9.9.9/31