31位掩码的IPv4地址

31位掩码的IPv4地址

31位掩码的IPv4地址

前两天在查文档的时候发现路由器之间使用 31 位的 IPv4 地址互联,这让我一惊,查了一下发现试我自己孤陋寡闻了;早在2000年的时候就有 rfc3021 提出使用31位置掩码的地址作为互联地址来节省地址资源。

按照传统IPv4 CIDR 的算法,一个能正常使用的网段最小是30位的,地址空间内有2^2个地址,去除网络地址和全1的广播地址,还能够剩下两个地址供使用。随着公网环境IPv4地址的紧张,上面提到的RFC提出使用31位掩码地址用于P2P链路的互联;即把原先是网络地址和广播地址的这两个作为单播地址使用。再加上 RFC2644 废除了路由器的定向广播行为,使得主机位全部为1的地址几乎没有用途,使全1主机位地址更有理由被使用。

类似的,IPv6 环境也有/127位的地址用于点对点链路

Pv6 环境下主机位全1的地址用于anycast,IPv6原生就没有广播;

IPv6 Anycast地址在路由器互联场景下行为和Unicast一致,在不刻意设置anycast地址的情况下,anycast地址和Unicast地址没太大区别(仅在NDP协议行为上有区别)。

实验拓扑:

实验发现,现今主流的设备/系统均支持31位掩码的ipv4地址用于路由器互联,有的系统在使用的时候会提示慎重操作。

H3C 可以正常配置/31位掩码地址,无告警

Huawei 可以正常配置/31位掩码地址,告警提示

Ruijie 可以正常配置/31位掩码地址,告警提示

Vyos 可以正常配置/31位掩码地址,无告警

Cisco 可以正常配置/31位掩码地址,告警提示

Juniper 可以正常配置/31位掩码地址,无告警

ping 测试,经过测试所有ip地址互相ping均没有问题

抓包

ospf 实验中的测试设备均正常,无需特殊设置(ospf模式为p2p等)

完整配置

实验仅浅尝,未作全面测试,具体设备型号和版本见下面,暂时未发现/31用于网络设备互联时和常规地址有什么区别。

R1

## H3C VSR1000 Version 7.1.064, Release 1362P12##

#

sysname R1

#

router id 1.1.1.1

#

ospf 1

area 0.0.0.0

#

interface LoopBack0

ip address 1.1.1.1 255.255.255.255

ospf 1 area 0.0.0.0

#

interface GigabitEthernet1/0

port link-mode route

ip address 12.0.0.0 255.255.255.254

ospf 1 area 0.0.0.0

#

interface GigabitEthernet2/0

port link-mode route

ip address 16.0.0.0 255.255.255.254

ospf 1 area 0.0.0.0

### 下面是自动生成的

arp static 12.0.0.1 007a-0ec6-c900

arp static 16.0.0.1 50e2-b100-b603

#

R2

## HUAWEI NE40E Version 8.180 ##

#

sysname R2

#

router id 2.2.2.2

#

interface Ethernet1/0/0

undo shutdown

ip address 12.0.0.1 255.255.255.254

ospf enable 1 area 0.0.0.0

undo dcn

undo dcn mode vlan

#

interface Ethernet1/0/1

undo shutdown

ip address 23.0.0.0 255.255.255.254

ospf enable 1 area 0.0.0.0

undo dcn

undo dcn mode vlan

#

interface LoopBack0

ip address 2.2.2.2 255.255.255.255

ospf enable 1 area 0.0.0.0

#

ospf 1

area 0.0.0.0

#

undo dcn

#

R3

## Ruijie RG-NSE-Route(V1.06) ##

hostname R3

!

interface GigabitEthernet 0/0

ip address 23.0.0.1 255.255.255.254

ip ospf 1 area 0

!

interface GigabitEthernet 0/1

ip address 34.0.0.0 255.255.255.254

ip ospf 1 area 0

!

interface Loopback 0

ip address 3.3.3.3 255.255.255.255

ip ospf 1 area 0

!

router ospf 1

router-id 3.3.3.3

graceful-restart

area 0

R4

## VyOS 1.5-rolling-202403050022 ##

set system host-name R4

set interfaces ethernet eth0 address '34.0.0.1/31'

set interfaces ethernet eth1 address '45.0.0.0/31'

set interfaces loopback lo address '4.4.4.4/32'

set protocols ospf area 0

set protocols ospf interface eth0 area '0'

set protocols ospf interface eth1 area '0'

set protocols ospf interface lo area '0'

commit

R5

## Cisco CAT9K_IOSXE Version 17.10.01prd7 ##

hostname R5

!

ip routing

!

interface Loopback0

ip address 5.5.5.5 255.255.255.255

ip ospf 1 area 0

!

interface GigabitEthernet1/0/1

no switchport

ip address 45.0.0.1 255.255.255.254

ip ospf 1 area 0

!

interface GigabitEthernet1/0/2

no switchport

ip address 56.0.0.0 255.255.255.254

ip ospf 1 area 0

!

router ospf 1

router-id 5.5.5.5

!

R6

## Juniper vmx 22.3R1.11

set system host-name R6

set interfaces ge-0/0/0 unit 0 family inet address 56.0.0.1/31

set interfaces ge-0/0/1 unit 0 family inet address 16.0.0.1/31

set interfaces lo0 unit 0 family inet address 6.6.6.6/32

set routing-options router-id 6.6.6.6

set protocols ospf area 0.0.0.0 interface ge-0/0/0.0

set protocols ospf area 0.0.0.0 interface ge-0/0/1.0

set protocols ospf area 0.0.0.0 interface lo0.0

commit

参考

https://zhiliao.h3c.com/questions/dispcont/142486

https://zhuanlan.zhihu.com/p/457227328

https://www.rfc-editor.org/rfc/rfc3021

https://www.cnblogs.com/Primzahl/p/16009081.html

相关典藏

VERMICULAR IH 琺瑯鑄鐵電子鍋
仿bus365

VERMICULAR IH 琺瑯鑄鐵電子鍋

📅 11-30 👁️‍🗨️ 5275
网店怎么开?大概需要多少钱?手把手教你轻松起步!
365betribo88

网店怎么开?大概需要多少钱?手把手教你轻松起步!

📅 01-23 👁️‍🗨️ 9795
江湖X汉家江湖新版刀魔 刀魔打法思路与装备搭配
仿bus365

江湖X汉家江湖新版刀魔 刀魔打法思路与装备搭配

📅 08-02 👁️‍🗨️ 2212