14.1 基础知识回顾
- 应用广泛;
- OSPF的5中报文封装在IP报文中;
- OSPF是接口敏感性协议;
14.1.1 链路状态协议
RIP是距离矢量路由协议,以条数作为METRIC值,路由器发送路由表给邻居学习。
OSPF则是链路状态协议,传输的不是路由信息,而是链路状态,路由器把自己接口描述封装在报文中发送给邻居,自己运行SPF算法生成无环树。
链路状态数据库:勾画整个链路拓扑的数据库,在数据库的基础上运行SPF算法生成以自己为根的树,最终形成路由表
14.1.2 RouterID
OSPF域内唯一标识符;
RouterID选定原则:如果配置了Lookback接口,激活的Lookback接口中,IP地址最大的地址作为Lookback,如果没有配置Lookback接口,则是活动的物理接口中IP地址最大的地址。
一般来说,在大型网络规划中,如192.168.0.0/16网络,将192.168.200.0以后的C网络保留作为特殊应用,如服务器集群,链路互联地址,ROUTERID等。如1291.68.254.0/24中的192.168.254.*/30作为互联地址,192.168.255.*/32作为全网ROUTERID使用。
创建Lookback接口,分配地址,如1921.68.255.*/32,且同时在OSPF进程中用router-id手动方式指向这个地址,双保险,避免被人为的关掉。
14.1.3 DR、BDR
- MA多路访问的网络;
- 选举为了避免多台路由器时间两两建立邻居关系,泛洪恐怖;
- DR和BDR收集并泛洪给其他路由器;
- 所有路由器都需要和DR、BDR建立邻居关系,但是非DR、BDR路由器两两之间是不会建立邻居关系的。
- 优先级可以设定,不想当DR的设置为0即可;
- ROUTERID全网唯一;
- 稳定:新接进来的优先级即使很高,也不会设置为DR,否则会复位整个邻居关系,导致断网;
- OSPF用COST衡量,依据路由器接口而不是链路;
- 接口激活了OSPF后,就会有一个默认COST值,和带宽成反比;
- 邻居表是基础,建立临接关系,FULL状态;
- 建立临接关系后,会进行一序列的互动;
- DBD:LSA的头部摘要;
- LSU:存放LSA完整信息;
14.2 OSPF邻居关系建立过程
- 从DOWN状态开始,没有发现任何邻居,都有意愿发起和寻找邻居;
- A发HELLO包,存放A路由器在这条连路上已经发现的邻居,由于第一次发,所以邻居为0;
- B收到HELLO包,就知道这条链路有A在,并尝试建立邻居关系,这是把A置位初始化状态;
- B发现A后,把A的RouterID放在HELLO包里面,发给A;
- A收到HELLO包后,发现包里面有自己的RouterID,这是意味着双方建立了双向关系;
- TWO-WAY为一个里程碑式的阶段
进入预启动EX-START阶段;
- I为1表示协商主从,不是DR和BDR,主从决定后续LSA同步过程中谁占主动,谁来做主序列号;
- M为1表示后面还会有更多DBD报文发过来,为0表示最后一个DBD报文;
- MS为1表示自己认为自己应该主动,经过一序列对比,如谁RouterID大谁做主,最后决定谁来做主。
- A发送DBD报文,本地路由器LSA头部列表,(初始化协商;后续还有;自己认为自己主);
- B收到DBD报文后,B发现自己的RouterID比A大,这是回(初始化协商;后续还有;自己认为自己主);
- A收到DBD后,对方发过来的RouterID大,A接受现实,A把自己后续发的MS位都置位0,开始同步DBD信息;
- I位置位0,表示主动协商结束,序列号决定由谁做主了,这是就进入EXCHANGE状态;
所有DBD即LSA头部发送完成后,M置位0,表示发送结束了;进入LAODING状态;
可以开始装载需要的完整LSA信息;
如果还有LSA则LAODING状态,发送LSA的请求L.SR,对方收到LSR后应答LSU,LSU包含多条LSA详细信息;
经过一序列来回,双方LSA同步后,就进入FULL状态。
ATTEMP状态在帧中继状态下才会有的状态;
LSA特征,封装在LSU中,需要ACK确认;
OSPF域可以划分为多个区域;
- LAS封装在LSU里面,LSU指挥在建立邻居关系和拓扑变更时才会发送;
- 收到LSU后,查看里面的LSA:
- 如果本地LSDB中已经存在,则比较序列号,如果一样则丢弃,如果不一样,如果高则更新,并泛洪,如果低则丢弃;
- 如果本地LSDB不存在,则添加进OSPF数据,并发送ACK,同时泛洪,自己做SPF算法更新路由表。
14.3 OSPF的报文类型
14.4 OSPF多区域概念
- 使得OSPF可以支持更大的网络;
- 为后续产生ABR和ASBR做准备;
- 区域内部路由器:所有接口都属于一个区域;
- 骨干路由器:所有接口都属于骨干区域;
- 有且只有一个骨干区域area0,非骨干区域需要和骨干区域直连;
- 边界路由器ABR:接口有的属于骨干区域,有的属于非骨干区域;
14.4.1 配置
- 进程号:本地有效标识符;
- 路由器不同接口可以宣告进不同进程,但是从不同进程接口学到的信息不同传递给另一个进程,这是需要借助于路由重发布。
ROUTERID的配置,建设开设LOOKBACK接口,分配LOOKCACK地址,同时在路由进程里面手动指定一下ROUTERID
14.4.2 单区域配置
14.4.3 多区域配置
ABR关联区域不同
14.4.4 验证、查看
14.5 OSPF帧中继下使用
14.5.1 OSPF网络类型
- OSPF是接口敏感性协议;
- 帧中继是非广播模式的代表;
14.5.1.1 点对点
- 点多点链路两端只有两台设备;
- 只有两个,则没有必要选取BR和BDR,也就没有.6组播地址的必要;
14.5.1.2 广播型多路访问
以太网中,即使两台设置连接,只有两台,也会选择DR和BDR。
ip ospf network p2p,认为修改为定对点,加快邻居收敛速度,不选举DR和BDR了。
14.5.1.3 NBMA(重点)
NBMA下,探讨的重点,
RIPV1基于广播、RIPV2是基于组播;EIGRP、OSFP都是组播,如果不支持广播,那就更不支持组播。
14.6 LSA
14.6.1 LSA类型整体介绍
- RIP是更新自己的路由表给其他路由器,让路由器自己判断学哪些路由;
- OSPF传递的是LSA,即链路状态描述;
注此处说的OSPF域内有多个区域,本例子是三个区域
第一类LSA,每台路由器自己产生的关于自己直连链路的描述,每户居民产生自家门户信息,即每台路由器都产生自己直连链路的描述,即接口描述,泛洪范围仅仅只在本地区域,该区域内所有住户都能收到一类LSA,所有住户会同步各自的一类LSA,互相认识,知道了批次情况;
第二类LSA,在MA环境下由DR产生的关于MA的描述,如左上角村子,干道有多户,多路型访问,选择DR和BDR,有DR代表MA的网络向外进行描述。如土霸王为DR,所有的住户只能和土霸王建立邻居关系,两两之间不允许建邻居关系,不允许拜访,住户间往来需要借助二类LSA。
描述MA网络中所有路由器,由DR产生,泛洪二类LSA后,所有都知道MA网络中情况,区域中其他住户也就知道了MA网络中的其他信息。即由DR来发布二类LSA,包含MA网络中所有路由器,也包括DR本身。也是只能在本区域内泛洪。
第三类LSA,ABR在一类二类基础上产生的,有了一二类LSA后,区域内通讯没有问题了,但是区域间通讯需要借助村委会,村委会同时连接两个区域,两个区域的情况都知道,只是将一个区域的情况进行规划后,传递到另一个区域,这个LSA为三类LSA。即将区域的一类或者二类LSA归纳并产生出三类LSA,泛洪到其他区域中取。这样区域间通讯接可以解决了。
至此整个OSPF内部通讯可以了,
虽然OSPF内部通讯可以了,但是需要和外部通讯,则需要借助设备ASBR,连接了一个对于OSPF来说较为陌生的领域,作为整个OSPF的出口。ASBR知道外面的世界,但是对于OSPF内部来说是陌生的,当OSPF访问外面的世界是,由ASBR告诉他。
第五类LSA则是由ASBR向OSPF注入的外部路由描述,描述OSPF域外的路由情况。
如村委会在泛洪一类LSA信息时,还标注了自己是ABR,ASBR在发布一类LSA时,也会告诉大家它是ASBR。由于该区域的村名可以通过一类LSA知道ASBR在哪,但是一类LSA泛洪的是本区域,所以另外两个区域是不知道ASBR在哪的。
这时需要第四类LSA,该区域的ABR可以向骨干区域发送四类LSA,描述城门信息并泛洪,可以泛洪到所有区域,这是每个区域都可以通过四类LSA知道城门位置。
至此,OSPF区域内所有的就都知道城门在哪了。
- 第一类:每家每户都产生自家情况,泛洪范围为本区域;
- 第二类:在MA网络中,由DR产生,告知该区域有哪些路由器,泛洪区域为本区域;
- 第三类:经过一二类LSA的收集,需要在区域间路由,将一二类总结归纳通过三类传递,由ABR产生;
- 第五类:由ASBR产生,向OSPF注入外部路由,外部路由信息,会在整个OSPF域泛洪;但是OSPF域内部先得找到ASBR路由器;
- 第四类:由和ASBR同处一个区的ABR向OSPF区域发送四类LSA,关于ASBR的描述,在整个区域内泛洪;
14.6.2 LSA格式
14.6.3 LSA类型1:Router LSA
每台OSPF路由器都会产生,
不同的连接类型,LinkID和LinkDATA存放的数据,如上个案例的STUB网络,LinkID存放的是IP地址或者网络,LinkDATA存放的是地址或者掩码;
字段解释:
- 路由器两个直连接口都运行了OSPF链路;
- 该路由器的LSA1描述两条链路信息,会有两个LINK ID部分。
案例:三台路由器的连接接口宣告进区域0,给三台路由器设备lookback地址,并将R1的lookback地址宣告进区域0。R1和R2网线连接(MA),R2和R3串口连接。
路由器R1:配置lookback地址,将lookback地址以及接口地址都宣告进区域0
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#router ospf 1
R1(config-router)#network 192.168.12.1 0.0.0.0 area 0
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
路由器R2:配置lookback地址,将路由器两端接口宣告进区域0
R2(config)#interface fastEthernet 0/0
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#router ospf 1
R2(config-router)#network 192.168.12.2 0.0.0.0 are 0
R2(config)#router ospf 1
R2(config-router)#network 192.168.23.2 0.0.0.0 area 0
路由器R3:配置lookback地址,仅将接口宣告进区域0
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface serial 1/0
R3(config-if)#ip address 192.168.23.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#router ospf 1
R3(config-router)#network 192.168.23.3 0.0.0.0 area 0
查看三台路由器的邻居关系
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:30 192.168.12.2 FastEthernet0/0
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:30 192.168.23.3 Serial1/0
1.1.1.1 1 FULL/DR 00:00:34 192.168.12.1 FastEthernet0/0
R3#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ - 00:00:38 192.168.23.2 Serial1/0
路由器R1的OSPF库
R1#show ip ospf database
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 1340 0x80000002 0x0079C3 2
2.2.2.2 2.2.2.2 1024 0x80000004 0x00B5CE 3
3.3.3.3 3.3.3.3 1025 0x80000001 0x008CF3 2
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.12.1 1.1.1.1 1340 0x80000001 0x00C7EB
Router Link States (Area 0)表示1类LSA,
查看详细信息,如R1发出的LSA详细信息:
R1#show ip ospf database router 1.1.1.1
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 0)
LS age: 5
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 1.1.1.1
Advertising Router: 1.1.1.1
LS Seq Number: 80000004
Checksum: 0x34F1
Length: 48
Number of Links: 2
Link connected to: a Stub Network
(Link ID) Network/subnet number: 1.1.1.1
(Link Data) Network Mask: 255.255.255.255
Number of TOS metrics: 0
TOS 0 Metrics: 1
Link connected to: a Transit Network
(Link ID) Designated Router address: 192.168.12.1
(Link Data) Router Interface address: 192.168.12.1
Number of TOS metrics: 0
TOS 0 Metrics: 1
- R1宣告了两条链路,一个是Lookback,一个是Fastethernet链路;
- 对于STUB网,LinkID和LinkDATA对应的是地址和掩码;
- 对于传输网,LinkID存放的是DR的接口地址,LinkDATA存放的是和DR接口直连的接口地址;
查看R2的链路库
R2#show ip ospf database
OSPF Router with ID (2.2.2.2) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 836 0x80000009 0x002AF6 2
2.2.2.2 2.2.2.2 498 0x8000000A 0x00A9D4 3
3.3.3.3 3.3.3.3 343 0x80000007 0x0080F9 2
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.12.1 1.1.1.1 836 0x80000007 0x00BBF1
R2有两段链路,有三条链路,OSPF中串行用两条链路表示,如下:
R2#show ip ospf database router 2.2.2.2
OSPF Router with ID (2.2.2.2) (Process ID 1)
Router Link States (Area 0)
LS age: 633
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 2.2.2.2
Advertising Router: 2.2.2.2
LS Seq Number: 8000000A
Checksum: 0xA9D4
Length: 60
Number of Links: 3
Link connected to: another Router (point-to-point)
(Link ID) Neighboring Router ID: 3.3.3.3
(Link Data) Router Interface address: 192.168.23.2
Number of TOS metrics: 0
TOS 0 Metrics: 64
Link connected to: a Stub Network
(Link ID) Network/subnet number: 192.168.23.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 64
Link connected to: a Transit Network
(Link ID) Designated Router address: 192.168.12.1
(Link Data) Router Interface address: 192.168.12.2
Number of TOS metrics: 0
TOS 0 Metrics: 1
- 两条三段,其中:
- 串行链路产生两条:STUB 网络和对端邻居的描述;
- R1和R2直连链路,传输链路;
R3#show ip ospf database router 3.3.3.3
OSPF Router with ID (3.3.3.3) (Process ID 1)
Router Link States (Area 0)
LS age: 675
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 3.3.3.3
Advertising Router: 3.3.3.3
LS Seq Number: 80000007
Checksum: 0x80F9
Length: 48
Number of Links: 2
Link connected to: another Router (point-to-point)
(Link ID) Neighboring Router ID: 2.2.2.2
(Link Data) Router Interface address: 192.168.23.3
Number of TOS metrics: 0
TOS 0 Metrics: 64
Link connected to: a Stub Network
(Link ID) Network/subnet number: 192.168.23.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 64
R3两段,基于串口的STUB和对端邻居描述
14.6.4 LSA类型2:Network LSA
- Network LSA(Type2):由广播网或NBMA网络中的DR产生,
- Network LSA中记录了这一网络 上所有路由器的Router ID,
- 描述本网段的链路状态,在所属的区域内传播。
二类LSA不带METRIC值,需要借助一类LSA计算METRIC值。
接着LSA1的试验,二类由DR产生,描述当前的MA,描述当前网络中路由器的ID;
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:34 192.168.23.3 Serial1/0
1.1.1.1 1 FULL/DR 00:00:37 192.168.12.1 FastEthernet0/0
R1和R2为MA网络,会产生DR和BDR。可以看出R1为DR。
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:31 192.168.12.2 FastEthernet0/0
R2为BDR
查看R2的链路状态库
R2#show ip ospf database
OSPF Router with ID (2.2.2.2) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 1487 0x80000009 0x002AF6 2
2.2.2.2 2.2.2.2 1148 0x8000000A 0x00A9D4 3
3.3.3.3 3.3.3.3 994 0x80000007 0x0080F9 2
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.12.1 1.1.1.1 1486 0x80000007 0x00BBF1
如上面路由器R2有一条二类LSA,由DR路由器R1产生。
R2#show ip ospf database network
OSPF Router with ID (2.2.2.2) (Process ID 1)
Net Link States (Area 0)
Routing Bit Set on this LSA
LS age: 1705
Options: (No TOS-capability, DC)
LS Type: Network Links
Link State ID: 192.168.12.1 (address of Designated Router)
Advertising Router: 1.1.1.1
LS Seq Number: 80000007
Checksum: 0xBBF1
Length: 32
Network Mask: /24
Attached Router: 1.1.1.1
Attached Router: 2.2.2.2
二类LSA详情,由1.1.1.1产生,地址为12.1即R1和R2互联的R1接口地址.
以太网下,二类LSA掩码字段匹配,长度一致,如Network Mask: /24,二类掩码内容包括连接的路由器1.1.1.1和2.2.2.2
R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O 192.168.12.0/24 [110/65] via 192.168.23.2, 03:23:57, Serial1/0
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/66] via 192.168.23.2, 03:23:57, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
C 192.168.23.0/24 is directly connected, Serial1/0
如R3学到了R1的Lookback地址,R1和R2直连网段。
14.6.5 LSA类型3:Network Summary LSA
ABR不是说一台路由器的两个接口属于不同区域,而是说至少有一个接口属于骨干区域,还有其他接口属于非骨干区域的才叫ABR。
如图中间的路由器,一个接口属于区域0,一个接口属于区域1,同时掌握了两个区域完整的LSA1和LSA2,对一个区域内的LSA1和LSA2进行归纳和收集给另一个区域,这时区域1有了去区域0的LSA。
试验,在之前的基础上进行网络调整,左边为区域1,右边不动还为区域0
R1#conf t
R1(config)#no router ospf 1
R1(config)#router ospf 1
R1(config-router)#network 192.168.12.1 0.0.0.0 area 1
去除之前配置,重新配置OSPF
R2(config)#router ospf 1
R2(config-router)#no network 192.168.12.2 0.0.0.0 area 0
R2(config-router)#network 192.168.12.2 0.0.0.0 area 1
R2#show ip ospf interface fastEthernet 0/0
FastEthernet0/0 is up, line protocol is up
Internet Address 192.168.12.2/24, Area 1
Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) 1.1.1.1, Interface address 192.168.12.1
Backup Designated router (ID) 2.2.2.2, Interface address 192.168.12.2
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:02
Supports Link-local Signaling (LLS)
Index 1/1, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 1.1.1.1 (Designated Router)
Suppress hello for 0 neighbor(s)
查看接口详情,R2的F0/0接口已经属于区域1
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:35 192.168.23.3 Serial1/0
1.1.1.1 1 FULL/DR 00:00:32 192.168.12.1 FastEthernet0/0
已经选取了R1为DR
R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/2] via 192.168.12.1, 00:04:53, FastEthernet0/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
C 192.168.23.0/24 is directly connected, Serial1/0
学到了去往R1 1.1.1.1的路由,这时R2就成了一台ABR。
R2#show ip ospf database
OSPF Router with ID (2.2.2.2) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 356 0x8000000E 0x00D5A1 2
3.3.3.3 3.3.3.3 1194 0x80000008 0x007EFA 2
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
1.1.1.1 2.2.2.2 352 0x80000001 0x0033FB
192.168.12.0 2.2.2.2 352 0x80000001 0x00219D
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 357 0x80000003 0x0036F0 2
2.2.2.2 2.2.2.2 356 0x80000001 0x0040F3 1
Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
192.168.12.1 1.1.1.1 357 0x80000001 0x00C7EB
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
192.168.23.0 2.2.2.2 372 0x80000001 0x002054
R2的库分成了两个部分,即两个区域;同时拥有两个区域完整的LSA。区域0有一类和三类LSA,区域1有一类、二类和三类LSA。
R1#show ip ospf database
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 512 0x80000003 0x0036F0 2
2.2.2.2 2.2.2.2 513 0x80000001 0x0040F3 1
Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
192.168.12.1 1.1.1.1 512 0x80000001 0x00C7EB
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
192.168.23.0 2.2.2.2 513 0x80000001 0x002054
路由器R1中也收到了ABR路由器R2的外部路由信息;
R1#show ip ospf database summary
OSPF Router with ID (1.1.1.1) (Process ID 1)
Summary Net Link States (Area 1)
Routing Bit Set on this LSA
LS age: 569
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(Network)
Link State ID: 192.168.23.0 (summary Network Number)
Advertising Router: 2.2.2.2
LS Seq Number: 80000001
Checksum: 0x2054
Length: 28
Network Mask: /24
TOS: 0 Metric: 64
查看R1三类LSA的详细信息,路由器R2通告了区域0的网段192.168.23.0信息
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/65] via 192.168.12.2, 00:12:48, FastEthernet0/0
14.6.6 LSA类型4:ASBR Summary LSA
由ABR生成,ASBR宣告了内部接口,并没有宣告外部接口,这个OSPF域内对于192.168.1.0是未知的,也就是域外,为了让域内动态感知域外路由,需要进行路由重发布。
在之前的试验基础上,将R1的lookback地址不在宣告进OSPF,而是以注入的方式实现,即R1成ASBR路由器。
R1#configure terminal
R1(config)#router ospf 1
R1(config-router)#no network 1.1.1.1 0.0.0.0 area 1
R1(config-router)#redistribute connected subnets
R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 192.168.12.1, 00:00:21, FastEthernet0/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
C 192.168.23.0/24 is directly connected, Serial1/0
注入后,1.1.1.1的条目由以前的O变成了O E2类型
- 一类二类是O
- 三类是O IA
- 四类是O E2(E表示EXTERNAL,表示通过OSPF学习到的外部路由)
R3#show ip ospf database
OSPF Router with ID (3.3.3.3) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 967 0x80000010 0x00D1A3 2
3.3.3.3 3.3.3.3 1817 0x8000000A 0x007AFC 2
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.12.0 2.2.2.2 967 0x80000003 0x001D9F
Summary ASB Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
1.1.1.1 2.2.2.2 967 0x80000002 0x001915
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
1.1.1.0 1.1.1.1 836 0x80000002 0x00A3F4 0
这是R3上就有LSA4的了,Summary ASB
R3#show ip ospf database asbr-summary
OSPF Router with ID (3.3.3.3) (Process ID 1)
Summary ASB Link States (Area 0)
Routing Bit Set on this LSA
LS age: 1024
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(AS Boundary Router)
Link State ID: 1.1.1.1 (AS Boundary Router address)
Advertising Router: 2.2.2.2
LS Seq Number: 80000002
Checksum: 0x1915
Length: 28
Network Mask: /0
TOS: 0 Metric: 1
R3的LSA4路由是有R2 ABR通告的,R1为ASBR。
14.6.7 LSA类型5:AS External LSA
通过重发布的方式从外部注入OSPF域的。
接着LS4的试验
R3#show ip ospf database
OSPF Router with ID (3.3.3.3) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 1215 0x80000010 0x00D1A3 2
3.3.3.3 3.3.3.3 34 0x8000000B 0x0078FD 2
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.12.0 2.2.2.2 1215 0x80000003 0x001D9F
Summary ASB Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
1.1.1.1 2.2.2.2 1215 0x80000002 0x001915
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
1.1.1.0 1.1.1.1 1083 0x80000002 0x00A3F4 0
路由器R3中Type-5 AS External Link States为。4类是有R2 ABR通告的,5类是有R1 ASBR通告的。
R3#show ip ospf database external
OSPF Router with ID (3.3.3.3) (Process ID 1)
Type-5 AS External Link States
Routing Bit Set on this LSA
LS age: 1190
Options: (No TOS-capability, DC)
LS Type: AS External Link
Link State ID: 1.1.1.0 (External Network Number )
Advertising Router: 1.1.1.1
LS Seq Number: 80000002
Checksum: 0xA3F4
Length: 36
Network Mask: /24
Metric Type: 2 (Larger than any link state path)
TOS: 0
Metric: 20
Forward Address: 0.0.0.0
External Route Tag: 0
D作为ASBR,将10网段路由重发布进OSPF,重发布时可以指定是OE1还是OE2,默认METRIC值是20,默认类型是OE2。
OE2时可以指定外部METRIC值,这条路由后续恒定就是这个值不会改变。如路由器R3METRIC值恒定就是20,不会累加如接口METRIC值。
R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/65] via 192.168.23.2, 02:28:19, Serial1/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 192.168.23.2, 01:51:29, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
如果是OE1,重发布外部METRIC值为20,在OSPF中穿行时,经过每个入接口,都需要累加入接口METRIC值。
14.6.8 LSA类型7:NSSA External LSA
14.6.9 查看
14.7 OSPF特殊区域
随着路由器设备多,区域内泛洪会导致路由器负担重,如何精简、压缩路由,减少路由器负担。
- area0骨干区域,一个OSPF域有且只有一个骨干区域;其他就是常规区域。
- CO-1和CO-2是核心层;ABR是汇聚层;其他接入层。
- 区域2右边有一台ASBR将10.1.1.0重发布到OSPF域。
14.7.1 LSA情况
AREA2内,每台会产生1类LSA,但是每台VEB字段会不同,来标志位ASBR等路由器类型。没有二类LSA,因为本区域没有MA网络;三类LSA由,区域间;四类LSA没有,因为ASBR在区域2,同属一个区域,不需要告知去往ASBR的LSA4;五类LSA有,重发布,域类穿行。所以区域2类有1,3,5类LSA。
骨干区域四台路由器,都会产生一类LSA,部分VEB会置位,显示ABR;二类LSA没有,因为本区域没有MA网络;三类LSA有,两个区域;四类LSA,有,右边ABR泛洪;五类LSA,从右边过来。
AREA1内,一类LSA有;二类LSA有;三类LSA有;四类LSA有;五类LSA有。
14.7.2 STUB 区域
可以通过手动方式将除骨干区域外的其他区域配置为STUB区域。
对于AREA1,配置之前,AREA1之外进来的LSA3,4,5,对于AREA1区域来说,不需要知道太多关于外部的情况,完全可以精简,可以通过将AREA1配置为STUB区域。
- 如把AREA1配置为STUB区域,带来的影响就是AREA1内不会有LSA4,5的存在,即ABR将LSA4,5过滤了,不会在AREA1内泛洪了。
- 阻拦LSA4,5类的同时,下发一条三类的默认路由。(挡住的同时,留了个口子)。
- 减少AREA1内路由器的路由条目,还不影响路由可达性。
- 骨干区域不允许配置成STUB区域;
14.7.3 Totally stub 区域
Stub区域ABR屏蔽LSA4,5,用默认路由代替,但是其他区域LSA3依然可以进来,不够极致。
对于AREA1,只要向外走,只能从ABR走,通告LSA3对于该区域来说没有多大必要。
完全STUB区域,区域内只会有LSA1,2,LSA3,4,5都没有,会被默认路由取代。即ABR本身可以获取到LSA3,4,5,但是会被过滤掉,同时自动下发一条默认路由指向ABR。
骨干区域不允许配置成完全STUB区域;
1.7.4. NSSA:Not-so-stubby area
通常情况下,外部多条路由重发布进OSPF区域后,区域内路由器会充斥着多条外部路由,增加负担。这时通过配置STUB区域,来过滤4,5类,可是3类还是可以通过,一定程度较少路由表。
但是如果AREA1下还连接了另一个动态区域,出于优化的目的,将AREA1配置成了STUB区域,由于STUB区域不能再重发布;如何让AREA1的STUB区域即阻挡4,5类LSA,同时又允许重发布的动作,有点自相矛盾,这时就不能设置成STUB区域了。
NSSA是在STUB的基础上做的修改,STUB区域不会收到4,5类,本地也不允许注入外部路由,骨干区域也不允许配置成任何形式的特殊区域。
如果需要从本地引入外部路由,即利用7类LSA,如图中AREA2,在区域内泛洪,代表是ON1和ON2;
NSSA,配置后,区域内不允许接收从骨干区域及其他区域过来的4,5类LSA,同时本地允许注入外部路由,在NSSA区域注入的外部路由是以7类LSA泛洪,当7类LSA需要穿越ABR进入骨干区域后,7类LSA只允许存活在NSSA区域,不允许出NSSA区域,如果需要出NSSA,则ABR会将7类LSA转换成5类LSA。
注意:外部注入动作是在本地发生,
14.7.5 特殊区域和LSA关系
stub区域可以允许一类、二类LSA,以及三类默认路由;
NSSA区域允许一类、二类、三类以及7类路由,但是出该区域后,7类会被ABR转换为5类;
骨干区域允许一类、二类、三类、四类、五类LSA;
标准区域允许一类、二类、三类、四类、五类LSA;
骨干区域、常规区域、STUB区域、NSSA区域泛洪范围;
注意:非骨干区域间不允许传递LSA
OSPF区域和对应LSA类型对照表
14.7.6 配置
有接口属于该区域的路由器都需要做相应的配置,如R1和R2都属于AREA1,则都需要在路由进程下配置。
类似STUB配置,不同点在于ABR配置,可以调整自动下发的默认路由COST值。
一样本区域都需要配置。
NSSA区域ABR不会自动下发默认路由,手动注入默认路由,在NSSA区域泛洪,访问外部区域R3
会自动下发默认路由,也可以外部注入路由。
14.7.7 实例:特殊区域应用
绘制了核心层和汇聚层,省略接入层。
可以将各个区域设置为STUB区域,减少路由表。还可以进一步设备为完全STUB区。
14.8 试验
14.8.1 标准配置
分为三个区域
路由器R1:配置lookback地址,将接口地址和lookback地址宣告进区域1
R1#configure terminal
R1(config)#interface serial 0/0
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#end
R1(config)#router ospf 1
R1(config-router)#network 192.168.12.1 0.0.0.0 area 1
R1(config-router)#network 1.1.1.1 0.0.0.0 area 1
路由器R2:配置lookback地址,将两端接口分别宣告进区域1和区域0
R2#configure terminal
R2(config)#interface serial 0/0
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#router ospf 1
R2(config-router)#network 192.168.12.2 0.0.0.0 area 1
R2(config)#interface serial 0/1
R2(config-if)#ip address 192.168.23.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#router ospf 1
R2(config-router)#network 192.168.23.2 0.0.0.0 area 0
路由器R3:设置lookback地址,将两端接口分别宣告进区域0和区域2
R3(config)#interface serial 0/0
R3(config-if)#ip address 192.168.23.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#router ospf 1
R3(config-router)#network 192.168.23.3 0.0.0.0 area 0
R3(config)#interface serial 0/1
R3(config-if)#ip address 192.168.34.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#router ospf 1
R3(config-router)#network 192.168.34.3 0.0.0.0 are
R3(config-router)#network 192.168.34.3 0.0.0.0 area 2
路由器R4:设置lookback地址,将接口宣告进区域2
R4(config)#interface serial 0/0
R4(config-if)#ip address 192.168.34.4 255.255.255.0
R4(config-if)#no shutdown
R4(config)#interface loopback 0
R4(config-if)#ip address 4.4.4.4 255.255.255.0
R4(config-if)#no shutdown
R4(config)#router ospf 1
R4(config-router)#network 192.168.34.4 0.0.0.0 area 2
14.8.2 查看邻居关系
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ - 00:00:31 192.168.12.2 Serial0/0
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:34 192.168.23.3 Serial0/1
1.1.1.1 0 FULL/ - 00:00:36 192.168.12.1 Serial0/0
R3#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ - 00:00:37 192.168.23.2 Serial0/0
4.4.4.4 0 FULL/ - 00:00:38 192.168.34.4 Serial0/1
R4#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:37 192.168.34.3 Serial0/0
14.8.3 查看路由表
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/128] via 192.168.12.2, 00:01:20, Serial0/0
O IA 192.168.34.0/24 [110/192] via 192.168.12.2, 00:01:20, Serial0/0
已经学到了两个网段192.168.23.0和192.168.34.0
14.8.4 查看LSA
R1#show ip ospf database
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 964 0x80000004 0x00B0DF 3
2.2.2.2 2.2.2.2 125 0x80000002 0x00326F 2
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
192.168.23.0 2.2.2.2 121 0x80000001 0x002054
192.168.34.0 2.2.2.2 121 0x80000001 0x0029FF
- 一类LSA:
- R1:3个链路,一个是LOOKBACK,一个是连接链路,一个是对端描述;
- R2:2个链路,一个是连接链路,一个是对端描述;
- 三类LSA,从骨干区域过来的两个。
14.8.5 重发布
从R4将lookback接口重发布
R4(config)#router ospf 1
R4(config-router)#redistribute connected subnets
默认METRIC是20,默认类型为OE2类型,始终不变
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
4.0.0.0/24 is subnetted, 1 subnets
O E2 4.4.4.0 [110/20] via 192.168.12.2, 00:00:18, Serial0/0
O IA 192.168.23.0/24 [110/128] via 192.168.12.2, 00:06:57, Serial0/0
O IA 192.168.34.0/24 [110/192] via 192.168.12.2, 00:06:57, Serial0/0
从R1上就可以看到R4重发布的lookback接口路由了。
14.8.6 STUB
R1#show ip ospf database
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 1364 0x80000004 0x00B0DF 3
2.2.2.2 2.2.2.2 525 0x80000002 0x00326F 2
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
192.168.23.0 2.2.2.2 521 0x80000001 0x002054
192.168.34.0 2.2.2.2 521 0x80000001 0x0029FF
Summary ASB Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
4.4.4.4 2.2.2.2 127 0x80000001 0x008B18
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
4.4.4.0 4.4.4.4 133 0x80000001 0x00DEA5 0
一旦重发布,R1上有5类LSA,外部LSA。还有4类LSA4.4.4.4
R1#show ip ospf database asbr-summary
OSPF Router with ID (1.1.1.1) (Process ID 1)
Summary ASB Link States (Area 1)
Routing Bit Set on this LSA
LS age: 202
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(AS Boundary Router)
Link State ID: 4.4.4.4 (AS Boundary Router address)
Advertising Router: 2.2.2.2
LS Seq Number: 80000001
Checksum: 0x8B18
Length: 28
Network Mask: /0
TOS: 0 Metric: 128
4类LSA详情,由2.2.2.2通告的,关于ASBR的。
R1#conf t
R1(config-router)#area 1 stub
R2#conf t
R2(config)#router ospf 1
R2(config-router)#area 1 stub
强R1配置为STUB区域
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 192.168.12.2 to network 0.0.0.0
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/128] via 192.168.12.2, 00:00:17, Serial0/0
O IA 192.168.34.0/24 [110/192] via 192.168.12.2, 00:00:17, Serial0/0
O*IA 0.0.0.0/0 [110/65] via 192.168.12.2, 00:00:17, Serial0/0
自动产生默认路由了,没有之前重发布的路由了。
外部路由消失了,STUB区域过滤外部重发布路由,允许OSPF区域内的三类路由。
R1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/59/68 ms
虽然路由没了,但是PING还是可以PING通的,因为有默认路由。
R1#show ip ospf database
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 142 0x80000006 0x00CAC5 3
2.2.2.2 2.2.2.2 143 0x80000004 0x004C55 2
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 2.2.2.2 149 0x80000001 0x0075C0
192.168.23.0 2.2.2.2 149 0x80000002 0x003C39
192.168.34.0 2.2.2.2 149 0x80000002 0x0045E4
之前看到的4类和5类也没了,取而代之的是3类的LSA多了条默认路由。
14.8.7 Totally STUB
R2#conf t
R2(config)#router ospf 1
R2(config-router)#area 1 stub no-summary
路由表进一步精简了,只剩下默认路由了。
R1#show ip ospf database
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 340 0x80000006 0x00CAC5 3
2.2.2.2 2.2.2.2 341 0x80000004 0x004C55 2
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 2.2.2.2 44 0x80000002 0x0073C1
就剩下三类LSA默认路由
R1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/64/68 ms
路由依旧可达
STUB区域和完全STUB区域是不可以注入外部路由的。
14.8.8 NSSA
先将AREA1回复称常规区域
R1#conf t
R1(config)#router ospf 1
R1(config-router)#no area 1 stub
R2#conf t
R2(config)#router ospf 1
R2(config-router)#no area 1 stub
R2(config-router)#no area 1 stub no-summary
去除R1的LOOKBACK在OSPF发布,改成可以重发布
R1(config)#router ospf 1
R1(config-router)#no network 1.1.1.1 0.0.0.0 area 1
R1(config-router)#end
重发布
R1(config)#router ospf 1
R1(config-router)#redistribute connected subnets
R1(config-router)#end
R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 192.168.12.1, 00:00:15, Serial0/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
4.0.0.0/24 is subnetted, 1 subnets
O E2 4.4.4.0 [110/20] via 192.168.23.3, 00:00:15, Serial0/1
C 192.168.23.0/24 is directly connected, Serial0/1
O IA 192.168.34.0/24 [110/128] via 192.168.23.3, 00:00:15, Serial0/1
R2就可以看到了。
R4#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/192] via 192.168.34.3, 00:19:25, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 192.168.34.3, 00:00:46, Serial0/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/128] via 192.168.34.3, 00:19:25, Serial0/0
C 192.168.34.0/24 is directly connected, Serial0/0
R4也可以看到
R4#show ip ospf database
OSPF Router with ID (4.4.4.4) (Process ID 1)
Router Link States (Area 2)
Link ID ADV Router Age Seq# Checksum Link count
3.3.3.3 3.3.3.3 1763 0x80000003 0x004718 2
4.4.4.4 4.4.4.4 1218 0x80000002 0x00EB6E 2
Summary Net Link States (Area 2)
Link ID ADV Router Age Seq# Checksum
192.168.12.0 3.3.3.3 1608 0x80000001 0x00FD3D
192.168.23.0 3.3.3.3 1839 0x80000001 0x00026E
Summary ASB Link States (Area 2)
Link ID ADV Router Age Seq# Checksum
1.1.1.1 3.3.3.3 101 0x80000001 0x00F7B3
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
1.1.1.0 1.1.1.1 107 0x80000001 0x00A5F3 0
4.4.4.0 4.4.4.4 1220 0x80000001 0x00DEA5 0
R4有两条一类LSA,三类LSA2条,4类LSA1条,5类LSA2条
R4(config)#router ospf 1
R4(config-router)#area 2 nssa
R3#conf t
R3(config)#router ospf 1
R3(config-router)#area 2 nssa
R4#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/192] via 192.168.34.3, 00:00:22, Serial0/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/128] via 192.168.34.3, 00:00:22, Serial0/0
C 192.168.34.0/24 is directly connected, Serial0/0
R4相比之前,配置后,1.1.1.0没了,从骨干区域过滤外部路由,即4.5类LSA
R4#show ip ospf database
OSPF Router with ID (4.4.4.4) (Process ID 1)
Router Link States (Area 2)
Link ID ADV Router Age Seq# Checksum Link count
3.3.3.3 3.3.3.3 23 0x80000006 0x00EC67 2
4.4.4.4 4.4.4.4 95 0x80000004 0x008DC4 2
Summary Net Link States (Area 2)
Link ID ADV Router Age Seq# Checksum
192.168.12.0 3.3.3.3 97 0x80000002 0x00A192
192.168.23.0 3.3.3.3 23 0x80000003 0x00A3C4
Type-7 AS External Link States (Area 2)
Link ID ADV Router Age Seq# Checksum Tag
4.4.4.0 4.4.4.4 128 0x80000001 0x006E7C 0
没有4.5类了,多了一个7类,即本地注入的外部路由,可以本区域内泛洪,只允许在NSSA泛洪,穿越ABR后,会被转成5类。
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
4.0.0.0/24 is subnetted, 1 subnets
O E2 4.4.4.0 [110/20] via 192.168.12.2, 00:02:41, Serial0/0
O IA 192.168.23.0/24 [110/128] via 192.168.12.2, 00:06:11, Serial0/0
O IA 192.168.34.0/24 [110/192] via 192.168.12.2, 00:06:11, Serial0/0
R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/128] via 192.168.23.2, 00:03:12, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 192.168.23.2, 00:03:12, Serial0/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
4.0.0.0/24 is subnetted, 1 subnets
O N2 4.4.4.0 [110/20] via 192.168.34.4, 00:03:12, Serial0/1
C 192.168.23.0/24 is directly connected, Serial0/0
C 192.168.34.0/24 is directly connected, Serial0/1
R1和R3的对比,关于重发布的4.4.4.0的路由由N2变成了E2,即7类转换成了5类。
R4#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/192] via 192.168.34.3, 00:04:35, Serial0/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/128] via 192.168.34.3, 00:04:35, Serial0/0
C 192.168.34.0/24 is directly connected, Serial0/0
没有到1.1.1.0的路由,而且也没有默认路由,所以PING不同
R4#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
这时可以在R3上手工注入默认路由
R3(config)#router ospf 1
R3(config-router)#area 2 nssa default-information-originate
R4#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 192.168.34.3 to network 0.0.0.0
O IA 192.168.12.0/24 [110/192] via 192.168.34.3, 00:06:32, Serial0/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/128] via 192.168.34.3, 00:06:32, Serial0/0
C 192.168.34.0/24 is directly connected, Serial0/0
O*N2 0.0.0.0/0 [110/1] via 192.168.34.3, 00:00:15, Serial0/0
R4上就有默认路由了,
R4#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/63/68 ms
可以PING通了
14.8.9 Totally NSSA
进一步试验,去除默认路由
R3(config)#router ospf 1
R3(config-router)#no area 2 nssa default-information-originate
R3(config)#router ospf 1
R3(config-router)#area 2 nssa no-summary
R4#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 192.168.34.3 to network 0.0.0.0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
C 192.168.34.0/24 is directly connected, Serial0/0
O*IA 0.0.0.0/0 [110/65] via 192.168.34.3, 00:00:30, Serial0/0
两条从其他区域过来的路由没了,由ABR自动出现了一条默认路由。
配置为TOTALLY NSSA后,从骨干区域过来的3,4,5类LSA过滤掉,同时ABR自动下发一条3类默认路由。
R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/128] via 192.168.23.2, 00:02:06, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 192.168.23.2, 00:02:06, Serial0/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
4.0.0.0/24 is subnetted, 1 subnets
O N2 4.4.4.0 [110/20] via 192.168.34.4, 00:02:06, Serial0/1
C 192.168.23.0/24 is directly connected, Serial0/0
C 192.168.34.0/24 is directly connected, Serial0/1
R3上依旧可以看见。
14.9 被动接口
为了让R2知道192.168.1.0网段,需要在R1上进行宣告,这是R1会尝试给PC发送HELLO包,但是底下根本没有路由器。
可以通过配置,这个接口就不会发送或者接收任何HELLO包,避免无效的泛洪。
宣告所有的,同时指定哪个接口不宣告。
14.10 注入默认路由
只有一条上连路由,可以通过一条默认路由取代。默认路由指向CO汇聚。
前提是CO本身有一条默认路由,然后用改命令将默认路由注入三台路由器。三台路由动态学习到这条默认路由。
如CO ip route 0.0.0.0 Co上联的下一跳地址。
当 CO本地默认路由失效,则注入的也会失效。如CO上联的断开了。
使用ALWAYS,则不管本地有没有默认路由,都会始终向本地域注入默认路由,而且永不失效。
14.11 路由汇总
外部路由汇总,由ASBR汇总,对5,7类汇总。
区域间汇总,只能汇总本区域明细,即对1,2类LSA汇总。
这个在R2上汇总是无效的,因为只能汇总本区域的。
14.12 Virtual-link
一个区域只能有一个骨干区域,其他区域必须和骨干区域直连。
通过搭桥,让区域1可以连到区域0。
14.12.1 试验
R1路由器:清除之前的OSPF配置,将lookback地址和接口地址宣告进区域2
R1(config)#no router ospf 1
R1(config)#router ospf 1
R1(config-router)#network 192.168.12.1 0.0.0.0 area 2
R1(config-router)#network 1.1.1.1 0.0.0.0 area 2
R2(config)#no router ospf 1
R2(config)#router ospf 1
R2(config-router)#network 192.168.12.2 0.0.0.0 area 2
R2(config-router)#network 192.168.23.2 0.0.0.0 area 1
R3(config)#no router ospf 1
R3(config)#router ospf 1
R3(config-router)#network 192.168.23.3 0.0.0.0 area 1
R3(config-router)#network 192.168.34.3 0.0.0.0 area 0
R4#conf t
R4(config)#no router ospf 1
R4(config)#router ospf 1
R4(config-router)#network 192.168.34.4 0.0.0.0 area 0
R4(config-router)#network 4.4.4.4 0.0.0.0 area 0
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
没有OSPF路由
R1#show ip ospf database
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 2)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 204 0x80000003 0x00B2DE 3
2.2.2.2 2.2.2.2 205 0x80000001 0x003172 2
只有本区域,虽然邻居关系都已经建立了
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ - 00:00:36 192.168.12.2 Serial0/0
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:34 192.168.23.3 Serial0/1
1.1.1.1 0 FULL/ - 00:00:30 192.168.12.1 Serial0/0
R3#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ - 00:00:32 192.168.23.2 Serial0/0
R4#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:33 192.168.34.3 Serial0/0
R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 192.168.12.1, 00:04:42, Serial0/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
C 192.168.23.0/24 is directly connected, Serial0/1
O IA 192.168.34.0/24 [110/128] via 192.168.23.3, 00:03:06, Serial0/1
R2路由表正常,去各个网段都有
R4#show ip os database
OSPF Router with ID (4.4.4.4) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
3.3.3.3 3.3.3.3 10 0x80000002 0x004917 2
4.4.4.4 4.4.4.4 9 0x80000003 0x00D564 3
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.23.0 3.3.3.3 356 0x80000001 0x00026E
R2(config)#router ospf 1
R2(config-router)#area 1 virtual-link 3.3.3.3
R3(config)#router ospf 1
R3(config-router)#area 1 virtual-link 2.2.2.2
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - - 192.168.23.3 OSPF_VL0
3.3.3.3 0 FULL/ - 00:00:35 192.168.23.3 Serial0/1
1.1.1.1 0 FULL/ - 00:00:32 192.168.12.1 Serial0/0
多了个3.3.3.3,永久不会DOWN,DEAD TIME 为空
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/193] via 192.168.12.2, 00:01:06, Serial0/0
O IA 192.168.23.0/24 [110/128] via 192.168.12.2, 00:01:42, Serial0/0
O IA 192.168.34.0/24 [110/192] via 192.168.12.2, 00:01:06, Serial0/0
R1的网段齐了
R1#show ip ospf database
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 2)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 679 0x80000003 0x00B2DE 3
2.2.2.2 2.2.2.2 127 0x80000002 0x00326F 2
Summary Net Link States (Area 2)
Link ID ADV Router Age Seq# Checksum
4.4.4.4 2.2.2.2 86 0x80000001 0x00A3FF
192.168.23.0 2.2.2.2 127 0x80000001 0x002054
192.168.34.0 2.2.2.2 86 0x80000001 0x0029FF
R2已经把LSA泛洪给了R1