感谢相关作者的分享:参考https://zhuanlan.zhihu.com/p/382147334对Stub区域特性的描述,“被设置为stub区域的区域不会学习其他区域的详细路由条目,为保证Stub区域能够到达自治系统外部,Stub区域的ABR将生成一条缺省路由(对应三类LSA),并发布给Stub区域中的其他路由器。”
现对上述特性进行以下实验验证。
实验拓扑:
步骤一、初始配置(无Stub,无引入外部路由)
首先配置三台路由器各接口的IP地址,然后配置OSPF
SW1:
ospf 1
area 1
netw 192.168.12.1 0.0.0.255
SW2:
ospf 1
area 1
netw 192.168.12.2 0.0.0.255
area 0
netw 192.168.23.2 0.0.0.255
SW3:
ospf 1
area 0
netw 192.168.23.3 0.0.0.255
上述初始配置完成后,分别查看SW1/SW2/SW3的LSDB:
dis ospf lsdb
SW1:
OSPF Process 1 with Router ID 1.1.1.1
Link State Database
Area: 0.0.0.1
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 1.1.1.1 1.1.1.1 139 36 80000005 0
Router 2.2.2.2 2.2.2.2 140 36 80000005 0
Network 192.168.12.2 2.2.2.2 135 32 80000002 0
Sum-Net 192.168.23.0 2.2.2.2 166 28 80000001 1
SW2:
OSPF Process 1 with Router ID 2.2.2.2
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 3.3.3.3 3.3.3.3 335 36 80000004 0
Router 2.2.2.2 2.2.2.2 334 36 80000005 0
Network 192.168.23.3 3.3.3.3 330 32 80000002 0
Sum-Net 192.168.12.0 2.2.2.2 400 28 80000001 1
Area: 0.0.0.1
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 1.1.1.1 1.1.1.1 375 36 80000005 0
Router 2.2.2.2 2.2.2.2 374 36 80000005 0
Network 192.168.12.2 2.2.2.2 370 32 80000002 0
Sum-Net 192.168.23.0 2.2.2.2 400 28 80000001 1
SW3:
OSPF Process 1 with Router ID 3.3.3.3
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 3.3.3.3 3.3.3.3 465 36 80000004 0
Router 2.2.2.2 2.2.2.2 466 36 80000005 0
Network 192.168.23.3 3.3.3.3 460 32 80000002 0
Sum-Net 192.168.12.0 2.2.2.2 532 28 80000001 1
步骤二、在SW3上引入外部路由,使其成为ASBR
int lo 1
ip ad 10.0.0.1 32
int lo 2
ip ad 10.0.0.2 32
int lo 3
ip ad 10.0.0.3 32
quit
ospf 1
import-route direct
完成上述操作后,再次查看三台路由器的LSDB:
SW1:
OSPF Process 1 with Router ID 1.1.1.1
Link State Database
Area: 0.0.0.1
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 1.1.1.1 1.1.1.1 1243 36 80000005 0
Router 2.2.2.2 2.2.2.2 1244 36 80000005 0
Network 192.168.12.2 2.2.2.2 1239 32 80000002 0
Sum-Net 192.168.23.0 2.2.2.2 1270 28 80000001 1
Sum-Asbr 3.3.3.3 2.2.2.2 435 28 80000001 1
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 10.0.0.1 3.3.3.3 436 36 80000001 1
External 10.0.0.3 3.3.3.3 436 36 80000001 1
External 10.0.0.2 3.3.3.3 436 36 80000001 1
External 3.3.3.3 3.3.3.3 436 36 80000001 1
External 192.168.23.0 3.3.3.3 436 36 80000001 1
SW2:
OSPF Process 1 with Router ID 2.2.2.2
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 3.3.3.3 3.3.3.3 610 36 80000005 0
Router 2.2.2.2 2.2.2.2 1378 36 80000005 0
Network 192.168.23.3 3.3.3.3 1374 32 80000002 0
Sum-Net 192.168.12.0 2.2.2.2 1444 28 80000001 1
Area: 0.0.0.1
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 1.1.1.1 1.1.1.1 1419 36 80000005 0
Router 2.2.2.2 2.2.2.2 1418 36 80000005 0
Network 192.168.12.2 2.2.2.2 1414 32 80000002 0
Sum-Net 192.168.23.0 2.2.2.2 1444 28 80000001 1
Sum-Asbr 3.3.3.3 2.2.2.2 609 28 80000001 1
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 10.0.0.1 3.3.3.3 610 36 80000001 1
External 10.0.0.3 3.3.3.3 610 36 80000001 1
External 10.0.0.2 3.3.3.3 610 36 80000001 1
External 3.3.3.3 3.3.3.3 610 36 80000001 1
External 192.168.23.0 3.3.3.3 610 36 80000001 1
SW3:
OSPF Process 1 with Router ID 3.3.3.3
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 3.3.3.3 3.3.3.3 762 36 80000005 0
Router 2.2.2.2 2.2.2.2 1532 36 80000005 0
Network 192.168.23.3 3.3.3.3 1526 32 80000002 0
Sum-Net 192.168.12.0 2.2.2.2 1598 28 80000001 1
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 10.0.0.1 3.3.3.3 762 36 80000001 1
External 10.0.0.3 3.3.3.3 762 36 80000001 1
External 10.0.0.2 3.3.3.3 762 36 80000001 1
External 3.3.3.3 3.3.3.3 762 36 80000001 1
External 192.168.23.0 3.3.3.3 762 36 80000001 1
可以看到,相较于引入外部路由前的LSDB,各路由器的LSDB都增加了5类LSA(AS External LSA);
此外从SW1和SW2的LSDB中可以看到,在area 1中增加了4类LSA(ASBR-summary LSA)的信息:
Type LinkState ID AdvRouter
Sum-Asbr 3.3.3.3 2.2.2.2
该4类LSA描述的目标网络是本实验拓扑中ASBR(SW3)的Router ID(3.3.3.3),由ABR(SW2)发出。
此时查看SW1和SW2的路由表:
SW1:
Destinations : 16 Routes : 16
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
3.3.3.3/32 O_ASE2 150 1 192.168.12.2 GE0/0
10.0.0.1/32 O_ASE2 150 1 192.168.12.2 GE0/0
10.0.0.2/32 O_ASE2 150 1 192.168.12.2 GE0/0
10.0.0.3/32 O_ASE2 150 1 192.168.12.2 GE0/0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.12.0/24 Direct 0 0 192.168.12.1 GE0/0
192.168.12.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.12.255/32 Direct 0 0 192.168.12.1 GE0/0
192.168.23.0/24 O_INTER 10 2 192.168.12.2 GE0/0
SW2:
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
2.2.2.2/32 Direct 0 0 127.0.0.1 InLoop0
3.3.3.3/32 O_ASE2 150 1 192.168.23.3 GE0/1
10.0.0.1/32 O_ASE2 150 1 192.168.23.3 GE0/1
10.0.0.2/32 O_ASE2 150 1 192.168.23.3 GE0/1
10.0.0.3/32 O_ASE2 150 1 192.168.23.3 GE0/1
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.12.0/24 Direct 0 0 192.168.12.2 GE0/0
192.168.12.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.12.255/32 Direct 0 0 192.168.12.2 GE0/0
192.168.23.0/24 Direct 0 0 192.168.23.2 GE0/1
192.168.23.2/32 Direct 0 0 127.0.0.1 InLoop0
可以看到SW1和SW2均以第二类外部路由(O_ASE2)的形式学习到去往3.3.3.3和10.0.0.1、10.0.0.2和10.0.0.3的路由。
步骤三、使area 1变为Stub区域
在SW1和SW2上分别进行以下操作:
ospf 1
area 1
stub
完成上述操作后等待SW1和SW2之间的邻居关系重新建立。
此时再次查看SW1和SW2上的LSDB:
SW1:
OSPF Process 1 with Router ID 1.1.1.1
Link State Database
Area: 0.0.0.1
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 1.1.1.1 1.1.1.1 236 36 80000004 0
Router 2.2.2.2 2.2.2.2 237 36 80000003 0
Network 192.168.12.2 2.2.2.2 231 32 80000002 0
Sum-Net 0.0.0.0 2.2.2.2 277 28 80000001 1
Sum-Net 192.168.23.0 2.2.2.2 277 28 80000001 1
从SW1的LSDB中发现area 1内已经没有了4类LSA,取而代之的是一条新增的3类LSA(Summary LSA):
Sum-Net 0.0.0.0 2.2.2.2 277 28 80000001 1
同时所有5类LSA也没有了,证明此时SW1的LSDB将不再受到外部引入路由变化带来的影响。
SW2:
OSPF Process 1 with Router ID 2.2.2.2
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 3.3.3.3 3.3.3.3 981 36 80000006 0
Router 2.2.2.2 2.2.2.2 48 36 80000007 0
Network 192.168.23.3 3.3.3.3 45 32 80000004 0
Sum-Net 192.168.12.0 2.2.2.2 116 28 80000003 1
Area: 0.0.0.1
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 1.1.1.1 1.1.1.1 381 36 80000004 0
Router 2.2.2.2 2.2.2.2 380 36 80000003 0
Network 192.168.12.2 2.2.2.2 375 32 80000002 0
Sum-Net 0.0.0.0 2.2.2.2 420 28 80000001 1
Sum-Net 192.168.23.0 2.2.2.2 420 28 80000001 1
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 10.0.0.1 3.3.3.3 981 36 80000002 1
External 10.0.0.3 3.3.3.3 981 36 80000002 1
External 10.0.0.2 3.3.3.3 981 36 80000002 1
External 3.3.3.3 3.3.3.3 981 36 80000002 1
External 192.168.23.0 3.3.3.3 981 36 80000002 1
发现SW2的area 1中的4类LSA也被替换为一条3类LSA:
Sum-Net 0.0.0.0 2.2.2.2 420 28 80000001 1
另外,可以看到在SW1和SW2上新增的这条3类LSA由本实验拓扑中的ABR(SW2)(AdvRoute 2.2.2.2)发出。
最后查看SW1和SW2的路由表:
SW1:
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 O_INTER 10 2 192.168.12.2 GE0/0
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.12.0/24 Direct 0 0 192.168.12.1 GE0/0
192.168.12.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.12.255/32 Direct 0 0 192.168.12.1 GE0/0
192.168.23.0/24 O_INTER 10 2 192.168.12.2 GE0/0
SW2:
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
2.2.2.2/32 Direct 0 0 127.0.0.1 InLoop0
3.3.3.3/32 O_ASE2 150 1 192.168.23.3 GE0/1
10.0.0.1/32 O_ASE2 150 1 192.168.23.3 GE0/1
10.0.0.2/32 O_ASE2 150 1 192.168.23.3 GE0/1
10.0.0.3/32 O_ASE2 150 1 192.168.23.3 GE0/1
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.12.0/24 Direct 0 0 192.168.12.2 GE0/0
192.168.12.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.12.255/32 Direct 0 0 192.168.12.2 GE0/0
192.168.23.0/24 Direct 0 0 192.168.23.2 GE0/1
192.168.23.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.23.255/32 Direct 0 0 192.168.23.2 GE0/1
发现SW2的路由表没有变化,而SW1的路由表中原本去往3.3.3.3、10.0.0.1、10.0.0.2和10.0.0.3的第二类外部路由已经被一条下一跳为ABR(SW2)的默认路由取代:
0.0.0.0/0 O_INTER 10 2 192.168.12.2 GE0/0
该默认路由的类型为区域内路由(O_INTER)。
在SW1上尝试ping 10.0.0.1:
<sw1>ping 10.0.0.1
Ping 10.0.0.1 (10.0.0.1): 56 data bytes, press CTRL+C to break
56 bytes from 10.0.0.1: icmp_seq=0 ttl=254 time=1.000 ms
56 bytes from 10.0.0.1: icmp_seq=1 ttl=254 time=0.000 ms
56 bytes from 10.0.0.1: icmp_seq=2 ttl=254 time=0.000 ms
56 bytes from 10.0.0.1: icmp_seq=3 ttl=254 time=0.000 ms
56 bytes from 10.0.0.1: icmp_seq=4 ttl=254 time=1.000 ms
可以ping通,至此实验完成。