编辑:银河教育时间:2019-10-28 07:09:22来源:
今天要讲的CCNP知识是关于ospf的。ospf首先发送hello包建立邻居,然后交换拓扑数据库,最后根据拓扑数据库计算出最佳路由然后放入路由表中。而拓扑数据库包含LSA,LSA最主要的有以下几类。
1类:也叫区域内拓扑数据库,是区域内路由器通告的,用来描述自己。
2类:跟1类差不多,区别在于是由区域内的DR创建。
3类:网络汇总LSA,由ABR创建,用来被通告到其他的区域。
4类:ASBR汇总LSA.类似于3类LSA,只是用来通告前往ASBR.
5类:由ASBR创建,用于描述被注入ospf的路由,也就是被重分发的路由。
7类:类似于5类LSA,只是由nssa区域内的ASBR创建。
而今天涉及到的LSA类型包括1、2、3、5和7类LSA 。
末节区域:末节区域内的路由器不通告5类LSA,也就是说如果启用了末节区域重分发路由就不会起作用。但是可以用nssa末节区域末节区域。它使用7类LSA提供了像5类lsa那样的功能,这使得重分发路由还是能够起作用。有4种类型的末节区域。末节区域,绝对末节区域,nssa和绝对nssa。所有的末节区域都5类LSA通告到区域,绝对末节区域和绝对nssa连3类LSA也不通告,这使得路由表更小,而路由器处理路由使用的内存和cpu资源也更少。注意,配置为末节区域的区域内所有路由器都必须被配置为末节路由器,否者邻居关系将不能够正常建立。
网络拓扑图如下,采用6个思科路由器来组网:
全部配置如下:
r1:
in e0/0
ip add 192.168.1.1 255.255.255.0
no sh
ip ospf 1 a 0
r2:
in e0/1
ip add 192.168.1.2 255.255.255.0
no sh
ip ospf 1 a 0
in e0/0
ip add 192.168.2.1 255.255.255.0
no sh
ip ospf 1 a 0
r3:
in e0/1
ip add 192.168.2.2 255.255.255.0
no sh
ip ospf 1 a 0
in e0/0
ip add 192.168.3.1 255.255.255.0
no sh
ip ospf 1 a 1
router ospf 1
area 1 nssa
r4:
in e0/1
ip add 192.168.4.1 255.255.255.0
no sh
ip ospf 1 a 1
in e0/2
ip add 192.168.5.1 255.255.255.0
no sh
ip ospf 1 a 1
in e0/1
ip add 192.168.4.1 255.255.255.0
no sh
router eigrp 1
net 192.168.4.0
redistribute ospf 1 metric 1000 100 255 1 1500
router ospf 1
redistribute eigrp 1 subnets metric 25 metric-type 1
area 1 nssa
r5:
in e0/1
ip add 192.168.4.2 255.255.255.0
no sh
in loop 1
ip add 172.16.0.1 255.255.255.0
router eigrp 1
net 192.168.4.0
no au
net 172.16.0.0 0.0.0.255
r6:
in e0/0
ip add 192.168.5.2 255.255.255.0
http://www.luyouqiwang.com/14445/
no sh
router ospf 1
net 192.168.5.2 0.0.0.0 a 1
area 1 nssa
验证命令:
show ip ro
show ip ospf nei
show ip ospf data
先看看没有配置为nssa以前r3上show ip ospf data的输出
R3#show ip ospf data
OSPF Router with ID (192.168.2.2) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
192.168.1.1 192.168.1.1 175 0x80000004 0x0091E7 1
192.168.1.2 192.168.1.2 84 0x80000006 0x002A58 2
192.168.2.2 192.168.2.2 63 0x80000007 0x0090DD 1
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.1.1 192.168.1.1 175 0x80000003 0x00B2D6
192.168.2.1 192.168.1.2 84 0x80000003 0x00B8CC
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.3.0 192.168.2.2 63 0x80000003 0x00F066
192.168.5.0 192.168.2.2 86 0x80000001 0x00430A
Summary ASB Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.3.2 192.168.2.2 86 0x80000001 0x00D283
Router Link States (Area 1)(1类LSA)
Link ID ADV Router Age Seq# Checksum Link count
192.168.2.2 192.168.2.2 66 0x8000000A 0x009CCC 1
192.168.3.2 192.168.3.2 101 0x8000000C 0x00BEAB 2
192.168.5.2 192.168.5.2 123 0x80000007 0x00A3BE 1
Net Link States (Area 1)(2类LSA)
Link ID ADV Router Age Seq# Checksum
192.168.3.2 192.168.3.2 96 0x80000004 0x00A5D8
192.168.5.2 192.168.5.2 118 0x80000004 0x00A0D6
Summary Net Link States (Area 1)(3类LSA)
Link ID ADV Router Age Seq# Checksum
192.168.1.0 192.168.2.2 66 0x80000005 0x0067E5
192.168.2.0 192.168.2.2 66 0x80000005 0x00F75E
Type-5 AS External Link States(5类LSA)
Link ID ADV Router Age Seq# Checksum Tag
172.16.0.0 192.168.3.2 182 0x80000001 0x00E30D 0
192.168.4.0 192.168.3.2 187 0x80000001 0x008BB4 0
发现其中有5类LSA。
r3路由表:
R3#show ip ro
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
172.16.0.0/24 is subnetted, 1 subnets
O E1 172.16.0.0 [110/35] via 192.168.3.2, 00:06:09, Ethernet0/0
O E1 192.168.4.0/24 [110/35] via 192.168.3.2, 00:06:09, Ethernet0/0
O 192.168.5.0/24 [110/20] via 192.168.3.2, 00:06:09, Ethernet0/0
O 192.168.1.0/24 [110/20] via 192.168.2.1, 00:06:19, Ethernet0/1
C 192.168.2.0/24 is directly connected, Ethernet0/1
C 192.168.3.0/24 is directly connected, Ethernet0/0
其中有从eigrp分发到ospf中的两条外部路由。
r3上的邻居关系:
R3#show ip ospf nei
Neighbor ID Pri State Dead Time Address Interfa
192.168.1.2 1 FULL/DR 00:00:33 192.168.2.1 Etherne
192.168.3.2 1 FULL/DR 00:00:39 192.168.3.2 Etherne
只在1台路由器上配置为nssa,发现邻居关系断掉了。
R3(config)#router ospf 1
R3(config-router)#area 1 nssa
R3(config-router)#
*Mar 1 01:20:09.535: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.3.2 on Ethernet0/0
from FULL to DOWN, Neighbor Down: Adjacency forced to reset
R3(config-router)#do show ip ospf nei
Neighbor ID Pri State Dead Time Address Interface
192.168.1.2 1 FULL/DR 00:00:37 192.168.2.1 Ethernet0/1
192.168.3.2 1 DOWN/DROTHER - 192.168.3.2 Ethernet0/0
从show ip ospf nei中发现邻居192.168.3.2已经为DOWN状态了。现在我在r6和r4上也启用
nssa。
再看r3的邻居关系,发现已经恢复同192.168.3.2的邻居关系了。
R3#
*Mar 1 01:21:18.071: %SYS-5-CONFIG_I: Configured from console by console
R3#
*Mar 1 01:23:37.351: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.3.2 on Ethernet0/0
from LOADING to FULL, Loading Done
R3#show ip ospf nei
Neighbor ID Pri State Dead Time Address Interface
192.168.1.2 1 FULL/DR 00:00:30 192.168.2.1 Ethernet0/1
192.168.3.2 1 FULL/DR 00:00:37 192.168.3.2 Ethernet0/0
再看拓扑数据库,发现5类LSA已经没有了,但是多出了7类LSA.
R3#show ip ospf data
OSPF Router with ID (192.168.2.2) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
192.168.1.1 192.168.1.1 904 0x80000004 0x0091E7 1
192.168.1.2 192.168.1.2 813 0x80000006 0x002A58 2
192.168.2.2 192.168.2.2 304 0x80000008 0x0094D6 1
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.1.1 192.168.1.1 904 0x80000003 0x00B2D6
192.168.2.1 192.168.1.2 813 0x80000003 0x00B8CC
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.3.0 192.168.2.2 792 0x80000003 0x00F066
192.168.5.0 192.168.2.2 92 0x80000001 0x00430A
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
192.168.2.2 192.168.2.2 96 0x8000000C 0x00441B 1
192.168.3.2 192.168.3.2 82 0x80000010 0x005C04 2
192.168.5.2 192.168.5.2 82 0x80000009 0x004515 1
Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
192.168.3.2 192.168.3.2 95 0x80000006 0x00472F
192.168.5.2 192.168.5.2 82 0x80000006 0x00422D
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
192.168.1.0 192.168.2.2 307 0x80000006 0x000B3B
192.168.2.0 192.168.2.2 307 0x80000006 0x009BB3
Type-7 AS External Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Tag
172.16.0.0 192.168.3.2 104 0x80000001 0x00CEA8 0
192.168.4.0 192.168.3.2 104 0x80000001 0x007650 0
Type-5 AS External Link States(这个5类应该是区域0的)
Link ID ADV Router Age Seq# Checksum Tag
172.16.0.0 192.168.2.2 95 0x80000001 0x006A18 0
192.168.4.0 192.168.2.2 162 0x80000001 0x0012BF 0
再看路由表:
R3#show ip ro
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
172.16.0.0/24 is subnetted, 1 subnets
O N1 172.16.0.0 [110/45] via 192.168.3.2, 00:03:00, Ethernet0/0
O N1 192.168.4.0/24 [110/45] via 192.168.3.2, 00:03:00, Ethernet0/0
O 192.168.5.0/24 [110/20] via 192.168.3.2, 00:03:00, Ethernet0/0
O 192.168.1.0/24 [110/20] via 192.168.2.1, 00:06:46, Ethernet0/1
C 192.168.2.0/24 is directly connected, Ethernet0/1
C 192.168.3.0/24 is directly connected, Ethernet0/0
路由表中O后面多了个N1.N1路由为ospf nssa外部类型1.差不多就这样了。
顺便再配下绝对nssa。
r3:
area 1 nssa no-summary
其余路由器上的配置还是相同,不必修改。
现在r3上拓扑数据库的输出
R3#show ip ospf data
OSPF Router with ID (192.168.2.2) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
192.168.1.1 192.168.1.1 1666 0x80000004 0x0091E7 1
192.168.1.2 192.168.1.2 1575 0x80000006 0x002A58 2
192.168.2.2 192.168.2.2 1067 0x80000008 0x0094D6 1
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.1.1 192.168.1.1 1666 0x80000003 0x00B2D6
192.168.2.1 192.168.1.2 1575 0x80000003 0x00B8CC
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.3.0 192.168.2.2 1554 0x80000003 0x00F066
192.168.5.0 192.168.2.2 854 0x80000001 0x00430A
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
192.168.2.2 192.168.2.2 859 0x8000000C 0x00441B 1
192.168.3.2 192.168.3.2 844 0x80000010 0x005C04 2
192.168.5.2 192.168.5.2 844 0x80000009 0x004515 1
Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
192.168.3.2 192.168.3.2 858 0x80000006 0x00472F
192.168.5.2 192.168.5.2 844 0x80000006 0x00422D
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 192.168.2.2 205 0x80000001 0x0013B5
Type-7 AS External Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Tag
172.16.0.0 192.168.3.2 867 0x80000001 0x00CEA8 0
192.168.4.0 192.168.3.2 867 0x80000001 0x007650 0
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
172.16.0.0 192.168.2.2 856 0x80000001 0x006A18 0
192.168.4.0 192.168.2.2 858 0x80000001 0x0012BF 0
3类LSA现在只有一条link id为0.0.0.0的了,而原来的192.168.1.0和192.168.2.0已经不见了。
上面的CCNP知识确实有点复杂,要通过思科认证考试可不是那么简单的,大家需要课后慢慢体会。