一、.什么是链路状态路由协议?
彼此之间通过发送HELLO信息建立邻居关系,形成第一张表邻居表,然后邻居彼此发送链路状态信息LSA(端口的IP前缀和状态),同步LSA,形成第二张表LSDB链路状态数据库,相当于有了整个网络的拜年,然后以自己为源,LSDB中的所有链路状态为目的,运行SPF(最短路径优先)算法,计算出到目的最短的COST,然后写入路由表的行为,叫链路状态协议。
二、OSPF的5个数据包
HELLO 用来建立和维持邻居关系,选举DR、BDR。
LSDBD 链路状态数据描述包。通告本端LSA,以摘要显示,即LSA的HEAD。
LSR 链路状态请求包。向对端请求自己没有的LSA。
LSU 链路状态更新包。回应对端请求,向其发送LSA。
LSAck 链路状态确认包。确认收到对端发送的LSA。
三、OSPF的七个状态
1、down 过去dead-interval时间未收到邻居发来的Hello报文
2、init 本端已受到邻居发来的Hello报文,但其中没有我端的router id,即邻居未受到我的hello报文。
3、2-way 双方都受到了Hello报文。若两端均为DRother的话即会停留在这个状态。
4、 Exstart 互相交换DBD报文,建立主从关系。
5、exchange 双方用DBD表述LSDB,互相交换。
6、loading 发送LSR。
7、full 对端的LSA本端均有,两端建立邻接关系。
四、OSPF的HELLO报文使用组播地址224.0.0.5
5.OSPF的5种网络类型:
五。OSPF支持的网络类型
1.广播:用组播224.0.0.5 224.0.0.6发送协议报文,选举DR/BDR。
2.非广播多路访问:用单播发送协议报文,选举DR/BDR,手工指定邻居
3.点到点
4.点到多点:
5.点到多点非广播
六、OSPF中LSA的7种常用类型
1.TYPE-1 内部LSA ,由内部所有路由器产生。
实例
在R1与R2之间配置OSPF
R1(config)#router ospf 100
R1(config-router)#router-id 1.1.1.1
R1(config-router)#net 1.1.1.0 0.0.0.255 ar 200
R1(config-router)#net 12.0.0.0 0.0.0.255 ar 200
2(config)#router ospf 100
R2(config-router)#router-id 2.2.2.2.
R2(config-router)#net 2.2.2.0 0.0.0.255 ar 200
R2(config-router)#net 12.0.0.0 0.0.0.255 ar 200
查看LSA TYPE-1
R2#show ip ospf database
OSPF Router with ID (2.2.2.2) (Process ID 100)
Router Link States (Area 200) 类型1
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 65 0x80000003 0x00CF95 3
2.2.2.2 2.2.2.2 64 0x80000002 0x00D18C 3
2.TYPE2 网络LSA,存在于广播网络中
拓扑同上
1.在R2与R3之间启动OSPF
R2(config)#router ospf 100
R2(config-router)#net 23.0.0.0 0.0.0.255 a 0
R3(config)#router ospf 100
R3(config-router)#router-id 3.3.3.3
R3(config-router)#net 3.3.3.0 0.0.0.255 a 0
R3(config-router)#net 23.0.0.0 0.0.0.255 a 0
查看详细信息:
R2#sh ip ospf database router 查看OSPF数据库的类型1的详细信息
OSPF Router with ID (2.2.2.2) (Process ID 100)
Router Link States (Area 0) 类型1
LS age: 378
Options: (No TOS-capability, DC)
LS Type: Router Links 链路1
Link State ID: 2.2.2.2 链路ID
Advertising Router: 2.2.2.2 传输过来的路由ID
LS Seq Number: 80000002 用于更新
Checksum: 0xCE4 检验和
Length: 36 长度
Area Border Router
Number of Links: 1 链路的号码,也是用于更新和查看
Link connected to: a Transit Network
(Link ID) Designated Router address: 23.0.0.1
(Link Data) Router Interface address: 23.0.0.1
Number of TOS metrics: 0
TOS 0 Metrics: 1 接口开销
在R3查看TYPE-2
R3#show ip os database
OSPF Router with ID (3.3.3.3) (Process ID 100)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 127 0x80000002 0x000CE4 1
3.3.3.3 3.3.3.3 127 0x80000002 0x004F7C 2
Net Link States (Area 0) 类型2
Link ID ADV Router Age Seq# Checksum
23.0.0.1 2.2.2.2 127 0x80000001 0x0008FD
Summary Net Link States (Area 0) 类型3
Link ID ADV Router Age Seq# Checksum
1.1.1.0 2.2.2.2 175 0x80000001 0x00B53B
2.2.2.0 2.2.2.2 175 0x80000001 0x000F1F
12.0.0.0 2.2.2.2 175 0x80000001 0x0033B5
分析OSPF七种LSA类型
拓扑如下图
TYPE -4
在R4 R5分别启RIP,并重发布路由信息。
R4(config-router)#version 2
R4(config-router)#no auto-summary
R4(config-router)#net 4.4.4.0
R4(config-router)#net 45.0.0.0
R5(config)#router ospf 100
R5(config-router)#router-id 5.5.5.5
R5(config-router)#net 5.5.5.0 0.0.0.255 a 200
R5(config-router)#net 51.0.0.0 0.0.0.255 a 200
R5(config-router)#redistribute rip sub tag 144
R5(config-router)#exit
R5(config)#router rip
R5(config-router)#version 2
R5(config-router)#no auto-summary
R5(config-router)#net 45.0.0.0
R5(config-router)#red ospf 100 metric 1
查看OSPF 数据库
查看路由表:
R2#sho ip route
O E2 4.4.4.0 [110/20] via 12.0.0.1, 00:02:16, Serial1/0
5.0.0.0/24 is subnetted, 1 subnets
O E2 45.0.0.0 [110/20] via 12.0.0.1, 00:02:17, Serial1/0
修改外部进入和路由类型为OE1,使COST进行累加
R5(config)#router ospf 100
R5(config-router)#no red rip
R5(config-router)#red rip metric 1 metric-type 1 tag 144 sub
查看路由表:
R1#sho ip route
4.0.0.0/24 is subnetted, 1 subnets
O E1 4.4.4.0 [110/65] via 51.0.0.1, 00:00:08, Serial1/2
45.0.0.0/24 is subnetted, 1 subnets
O E1 45.0.0.0 [110/65] via 51.0.0.1, 00:00:09, Serial1/2
查看类型5具体信息
R1#sho ip os da ex
OSPF Router with ID (1.1.1.1) (Process ID 100)
Type-5 AS External Link States
Routing Bit Set on this LSA
LS age: 1054
Options: (No TOS-capability, DC)
LS Type: AS External Link
Link State ID: 4.4.4.0 (External Network Number )
Advertising Router: 5.5.5.5 �D�D�D�D�D这个就是ASBR
LS Seq Number: 80000001
Checksum: 0xA8DA
Length: 36
Network Mask: /24
Metric Type: 1 (Comparable directly to link state metric)
TOS: 0
Metric: 1
Forward Address: 0.0.0.0
External Route Tag: 144
查看类型4具体信息
R1#show ip ospf database asbr-summary
OSPF Router with ID (1.1.1.1) (Process ID 100)
Summary ASB Link States (Area 0)
LS age: 205
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(AS Boundary Router)
Link State ID: 5.5.5.5 (AS Boundary Router address) 从ABR指定ASBR。我怎么知道到外部去,怎么走,谁告诉我,ABR告诉我ASBR怎么走。
Advertising Router: 1.1.1.1 谁产生的这个消息,ABR是起源
LS Seq Number: 80000001
Checksum: 0xF8EA
Length: 28
Network Mask: /0
TOS: 0 Metric: 64
虚链路:
R4(config)#no router rip
R4(config)#router ospf 100
R4(config-router)#router-id 4.4.4.4
R4(config-router)#net 5.5.5.0 0.0.0.255 a 100
R4(config-router)#net 45.0.0.0 0.0.0.255 a 100
R5(config)#router ospf 100
R5(config-router)#no red rip
R5(config-router)#net 45.0.0.0 0.0.0.255 a 100
R5(config-router)#exit
R5(config)#no router rip
R5(config-router)#do show ip route
51.0.0.0/24 is subnetted, 1 subnets
C 51.0.0.0 is directly connected, Serial1/2
1.0.0.0/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/65] via 51.0.0.2, 00:03:31, Serial1/2
2.0.0.0/24 is subnetted, 1 subnets
O IA 2.2.2.0 [110/129] via 51.0.0.2, 00:03:31, Serial1/2
5.0.0.0/24 is subnetted, 1 subnets
C 5.5.5.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/128] via 51.0.0.2, 00:03:31, Serial1/2
45.0.0.0/24 is subnetted, 1 subnets
C 45.0.0.0 is directly connected, Serial1/1
R4(config-router)#do 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
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
45.0.0.0/24 is subnetted, 1 subnets
C 45.0.0.0 is directly connected, Serial1/1
我们发现R4上没有任何的从R5传递过来的信息,因为R5不是跟area0直连的ARB,解决的方法就是在area200建立虚链路,让R4逻辑的跟area0建立连接的关系,将area200形成过渡的区域。
R1(config-router)#area 200 virtual-link 5.5.5.5
R5(config-router)#area 200 virtual-link 1.1.1.1 这里指的是对等体的路由ID而非接口IP地址,区域指定的是穿过的区域。
下面我们查看R4上的路由表:
R4(config-router)#do 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
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
45.0.0.0/24 is subnetted, 1 subnets
C 45.0.0.0 is directly connected, Serial1/1
R4(config-router)#do show ip route 看到学到了所有路由条目。
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial1/0
51.0.0.0/24 is subnetted, 1 subnets
O IA 51.0.0.0 [110/128] via 45.0.0.2, 00:02:02, Serial1/1
1.0.0.0/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/129] via 45.0.0.2, 00:01:53, Serial1/1
2.0.0.0/24 is subnetted, 1 subnets
O IA 2.2.2.0 [110/193] via 45.0.0.2, 00:01:53, Serial1/1
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
5.0.0.0/24 is subnetted, 1 subnets
O IA 5.5.5.0 [110/65] via 45.0.0.2, 00:02:02, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/192] via 45.0.0.2, 00:01:54, Serial1/1
45.0.0.0/24 is subnetted, 1 subnets
C 45.0.0.0 is directly connected, Serial1/1
查看虚链路信息:
R5#show ip os virtual-links
Virtual Link OSPF_VL1 to router 1.1.1.1 is up
Run as demand circuit
DoNotAge LSA allowed.
Transit area 200, via interface Serial1/2, Cost of using 64
Transmit Delay is 1 sec, State POINT_TO_POINT,
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:00
Adjacency State FULL (Hello suppressed) 这里必须为FULL
Index 1/3, retransmission queue length 0, number of retransmission 0
First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
Last retransmission scan length is 0, maximum is 0
Last retransmission scan time is 0 msec, maximum is 0 msec
这时拓扑逻辑变为以下:
查看LSDB:
R5#show ip os database
OSPF Router with ID (5.5.5.5) (Process ID 100)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 1 (DNA) 0x80000008 0x00B90B 4
2.2.2.2 2.2.2.2 1363 (DNA) 0x80000004 0x00CD8E 3
5.5.5.5 5.5.5.5 537 0x80000002 0x00632C 1
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
5.5.5.0 1.1.1.1 1343 (DNA) 0x80000001 0x0043A5
5.5.5.0 5.5.5.5 546 0x80000001 0x0048D0
45.0.0.0 5.5.5.5 546 0x80000001 0x002A91
51.0.0.0 1.1.1.1 1373 (DNA) 0x80000001 0x005471
51.0.0.0 5.5.5.5 546 0x80000001 0x00DBD9
所有通过虚拟路学习到的都以DNA做标记
汇总:
首在在R2上建立几个环回接口并宣告进入OSPF:
172.16.1.0 172.16.2.0 172.16.3.0 172.16.4.0
①在区域中汇总
R1(config-router)#area 100 range 172.16.0.0 255.255.248.0
查看汇总后的路由表:
R1#show ip route ospf 100
2.0.0.0/24 is subnetted, 1 subnets
O 2.2.2.0 [110/65] via 12.0.0.2, 00:00:45, Serial1/0
5.0.0.0/24 is subnetted, 1 subnets
O 5.5.5.0 [110/65] via 51.0.0.1, 00:00:45, Serial1/2
172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
O 172.16.4.1/32 [110/65] via 12.0.0.2, 00:00:45, Serial1/0
O 172.16.1.1/32 [110/65] via 12.0.0.2, 00:00:45, Serial1/0
O 172.16.0.0/21 is a summary, 00:00:45, Null0
O 172.16.3.1/32 [110/65] via 12.0.0.2, 00:00:45, Serial1/0
O 172.16.2.1/32 [110/65] via 12.0.0.2, 00:00:45, Serial1/0
45.0.0.0/24 is subnetted, 1 subnets
O IA 45.0.0.0 [110/128] via 51.0.0.1, 00:00:45, Serial1/2
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
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial1/0
51.0.0.0/24 is subnetted, 1 subnets
O IA 51.0.0.0 [110/128] via 45.0.0.2, 00:00:16, Serial1/1
1.0.0.0/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/129] via 45.0.0.2, 00:00:11, Serial1/1
2.0.0.0/24 is subnetted, 1 subnets
O IA 2.2.2.0 [110/193] via 45.0.0.2, 00:00:11, Serial1/1
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
5.0.0.0/24 is subnetted, 1 subnets
O IA 5.5.5.0 [110/65] via 45.0.0.2, 00:00:16, Serial1/1
172.16.0.0/32 is subnetted, 4 subnets
O IA 172.16.4.1 [110/193] via 45.0.0.2, 00:00:12, Serial1/1
O IA 172.16.1.1 [110/193] via 45.0.0.2, 00:00:12, Serial1/1
O IA 172.16.3.1 [110/193] via 45.0.0.2, 00:00:12, Serial1/1
O IA 172.16.2.1 [110/193] via 45.0.0.2, 00:00:12, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/192] via 45.0.0.2, 00:00:12, Serial1/1
45.0.0.0/24 is subnetted, 1 subnets
C 45.0.0.0 is directly connected, Serial1/1
我们看到从R4上没有查看到汇总信息,因为R5现在的身份不是area100中的一个普通的内部设备,而是通过启动虚链路后,形成了跟area0直连的一个ABR了
R5(config-router)#area 0 range 172.16.0.0 255.255.248.0
查看R4路由表:
R4#show ip ro
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
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial1/0
51.0.0.0/24 is subnetted, 1 subnets
O IA 51.0.0.0 [110/128] via 45.0.0.2, 00:07:34, Serial1/1
1.0.0.0/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/129] via 45.0.0.2, 00:07:28, Serial1/1
2.0.0.0/24 is subnetted, 1 subnets
O IA 2.2.2.0 [110/193] via 45.0.0.2, 00:07:28, Serial1/1
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
5.0.0.0/24 is subnetted, 1 subnets
O IA 5.5.5.0 [110/65] via 45.0.0.2, 00:07:34, Serial1/1
172.16.0.0/21 is subnetted, 1 subnets
O IA 172.16.0.0 [110/193] via 45.0.0.2, 00:02:38, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/192] via 45.0.0.2, 00:07:30, Serial1/1
45.0.0.0/24 is subnetted, 1 subnets
C 45.0.0.0 is directly connected, Serial1/1
由此可知,汇总必须在区域内所有ABR上执行。
我们在R2和R3之间启RIP,使R2成为ASBR,在R3上启用多环回口并宣告进入RIP
R2#show ip os database | begin Type-5
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
3.3.3.0 2.2.2.2 178 0x80000001 0x006995 144
23.0.0.0 2.2.2.2 178 0x80000001 0x00A947 144
122.22.22.0 2.2.2.2 178 0x80000001 0x00A1BF 144
122.22.23.0 2.2.2.2 178 0x80000001 0x0096C9 144
122.22.24.0 2.2.2.2 178 0x80000001 0x008BD3 144
122.22.25.0 2.2.2.2 178 0x80000001 0x0080DD 144
现在在R2上做汇总:因为他是ASBR
R2(config-router)#summary-address 122.22.16.0 255.255.240.0
R4#show ip ospf database | begin Type-5
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
3.3.3.0 2.2.2.2 1437 0x80000001 0x006995 144
23.0.0.0 2.2.2.2 1437 0x80000001 0x00A947 144
122.22.16.0 2.2.2.2 992 0x80000001 0x006E98 0
R4#show ip route
122.0.0.0/20 is subnetted, 1 subnets
O E2 122.22.16.0 [110/20] via 45.0.0.2, 00:17:12, Serial1/1
上INTERNET静态路由在OSPF中传递
R5(config)#int fa0/0
R5(config-if)#ip add 192.168.30.26 255.255.255.0
R5(config-if)#no sh
R5(config)#ip route 0.0.0.0 0.0.0.0 192.168.30.1
查看R5路由表:
R5(config)#do show ip rou
S* 0.0.0.0/0 [1/0] via 192.168.30.1
把默认路由放到ospf里面,以type-5的形式去传递:
R5(config-router)#default-information originate
我们到R2查看LSDB:
R2#show ip ospf database | begin Type-5
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
0.0.0.0 5.5.5.5 96 0x80000001 0x00A199 100
3.3.3.0 2.2.2.2 644 0x80000002 0x006796 144
23.0.0.0 2.2.2.2 644 0x80000002 0x00A748 144
122.22.16.0 2.2.2.2 133 0x80000002 0x006C99 0
查看路由表产生一条O*E2路由:
R2#show ip route
O*E2 0.0.0.0/0 [110/1] via 12.0.0.1, 00:00:11, Serial1/0
O*E2=到达外部去的默认路由!!!!通过TYPE-5传递进来的
特殊区域:
Stub区域(末节区域):
步骤:
1.配置ospf和rip,并且在发布rip进入到ospf,最终查看ospf的R5的路由表是完整
R1(config)#router ospf 100
R1(config-router)#router-id 1.1.1.1
R1(config-router)#net 1.1.1.0 0.0.0.255 a 0
R1(config-router)#net 12.0.0.0 0.0.0.255 a 0
R1(config-router)#net 51.0.0.0 0.0.0.255 a 100
R2(config)#router ospf 100
R2(config-router)#router-id 2.2.2.2
R2(config-router)#net 2.2.2.0 0.0.0.255 a 0
R2(config-router)#net 12.0.0.0 0.0.0.255 a 0
R2(config-router)#net 23.0.0.0 0.0.0.255 a 200
R3(config)#router ospf 100
R3(config-router)#router-id 3.3.3.3
R3(config-router)#net 3.3.3.0 0.0.0.255 a 200
R3(config-router)#net 23.0.0.0 0.0.0.255 a 200
R3(config-router)#red rip sub metric-type 1 tag 144
R3(config-router)#exit
R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#net 34.0.0.0
R3(config-router)#red ospf 100 metric 1
R4(config)#router rip
R4(config-router)#ver 2
R4(config-router)#noa u
R4(config-router)#no au
R4(config-router)#no auto-summary
R4(config-router)#net 4.4.4.0
R4(config-router)#net 34.0.0.0
R5(config)#router ospf 100
R5(config-router)#router-id 5.5.5.5
R5(config-router)#net 5.5.5.0 0.0.0.255 a 100
R5(config-router)#net 51.0.0.0 0.0.0.255 a 100
R5#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
34.0.0.0/24 is subnetted, 1 subnets
O E1 34.0.0.0 [110/149] via 51.0.0.1, 00:04:03, Serial1/2
51.0.0.0/24 is subnetted, 1 subnets
C 51.0.0.0 is directly connected, Serial1/2
1.0.0.0/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/65] via 51.0.0.1, 00:05:03, Serial1/2
2.0.0.0/24 is subnetted, 1 subnets
O IA 2.2.2.0 [110/129] via 51.0.0.1, 00:05:03, Serial1/2
3.0.0.0/24 is subnetted, 1 subnets
O IA 3.3.3.0 [110/130] via 51.0.0.1, 00:04:30, Serial1/2
4.0.0.0/24 is subnetted, 1 subnets
O E1 4.4.4.0 [110/149] via 51.0.0.1, 00:02:45, Serial1/2
5.0.0.0/24 is subnetted, 1 subnets
C 5.5.5.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.0.0.0 [110/129] via 51.0.0.1, 00:05:03, Serial1/2
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/128] via 51.0.0.1, 00:05:03, Serial1/2
R5#ping 4.4.4.4 source 5.5.5.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 112/132/164 ms
配置STUB区域:
R1(config)#router osp 100
R1(config-router)#area 100 stub
R5(config)#router ospf 100
R5(config-router)#area 100 stub
注:区域中的所有设备都需要改变自己的类型是stub区域。
这时区域100内除了R1(ABR)外均无法学习到Type-5的路由信息;产生一条O*IA的默认路由,起源于ABR
R5(config-router)#do show ip rou
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 51.0.0.1 to network 0.0.0.0
51.0.0.0/24 is subnetted, 1 subnets
C 51.0.0.0 is directly connected, Serial1/2
1.0.0.0/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/65] via 51.0.0.1, 00:00:54, Serial1/2
2.0.0.0/24 is subnetted, 1 subnets
O IA 2.2.2.0 [110/129] via 51.0.0.1, 00:00:54, Serial1/2
3.0.0.0/24 is subnetted, 1 subnets
O IA 3.3.3.0 [110/130] via 51.0.0.1, 00:00:54, Serial1/2
5.0.0.0/24 is subnetted, 1 subnets
C 5.5.5.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.0.0.0 [110/129] via 51.0.0.1, 00:00:54, Serial1/2
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/128] via 51.0.0.1, 00:00:55, Serial1/2
O*IA 0.0.0.0/0 [110/65] via 51.0.0.1, 00:00:55, Serial1/2
R5#ping 4.4.4.4 source 5.5.5.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
!!!!!
R5#show ip ospf database
OSPF Router with ID (5.5.5.5) (Process ID 100)
Router Link States (Area 100)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 1042 0x80000004 0x00CD51 2
5.5.5.5 5.5.5.5 1039 0x80000004 0x00BE30 3
Summary Net Link States (Area 100)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 1.1.1.1 1075 0x80000001 0x0093A6
1.1.1.0 1.1.1.1 1075 0x80000002 0x006DC8
2.2.2.0 1.1.1.1 1075 0x80000002 0x00CB27
3.3.3.0 1.1.1.1 1075 0x80000002 0x00B13D
12.0.0.0 1.1.1.1 1075 0x80000002 0x006D80
23.0.0.0 1.1.1.1 1075 0x80000002 0x00E7F9
未产生Type-5的信息:
完全末节区域:
R1(config-router)#area 100 stub no-summary
注:完全末节区域只需要ABR上配置即可。
R5#show ip ospf database 查看LSDB,Type-3的信息条目被过滤,只有Type-1的信息
OSPF Router with ID (5.5.5.5) (Process ID 100)
Router Link States (Area 100)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 38 0x80000006 0x00C953 2
5.5.5.5 5.5.5.5 1195 0x80000004 0x00BE30 3
Summary Net Link States (Area 100)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 1.1.1.1 47 0x80000001 0x0093A6
R5#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 51.0.0.1 to network 0.0.0.0
51.0.0.0/24 is subnetted, 1 subnets
C 51.0.0.0 is directly connected, Serial1/2
5.0.0.0/24 is subnetted, 1 subnets
C 5.5.5.0 is directly connected, Loopback0
O*IA 0.0.0.0/0 [110/65] via 51.0.0.1, 00:02:07, Serial1/2
以上证明。完全末梢区域只存在Type-1 Type-2的路由信息。
IS-IS中间系统到中间系统,他的level-1的路由就相当于这种路由!!!
删除所有末梢和完全末梢区域信息:
R1(config-router)#no area 100 stub no-summary
R1(config-router)#no area 100 stub
R5(config)#router ospf 100
R5(config-router)#no area 100 stub
NSSA的区域以及完全末节NSSA,他是工作在area0与ASBR之间的区域!!!!!!!!!!!!
R2(config-router)#area 200 nssa
R3(config)#router ospf 100
R3(config-router)#area 200 nssa
R3#show ip os database 查看LSDB,只看到Type-7的信息而没有Type-5的信息
OSPF Router with ID (3.3.3.3) (Process ID 100)
Router Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 68 0x80000005 0x00A129 2
3.3.3.3 3.3.3.3 64 0x80000006 0x001B90 3
Summary Net Link States (Area 200)
Link ID ADV Router Age Seq# Checksum
1.1.1.0 2.2.2.2 96 0x80000003 0x005791
2.2.2.0 2.2.2.2 96 0x80000003 0x00B075
5.5.5.0 2.2.2.2 96 0x80000002 0x004B52
12.0.0.0 2.2.2.2 96 0x80000003 0x00D40C
51.0.0.0 2.2.2.2 96 0x80000003 0x005A1F
Type-7 AS External Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Tag
4.4.4.0 3.3.3.3 69 0x80000001 0x00A5BC 144
34.0.0.0 3.3.3.3 69 0x80000001 0x007AD1 144
R2#show ip ospf database 在NSSA区域的ABR查看到Type-7变为Type-5的信息
OSPF Router with ID (2.2.2.2) (Process ID 100)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 871 0x80000005 0x00CE93 3
2.2.2.2 2.2.2.2 172 0x80000005 0x00D483 3
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
3.3.3.0 2.2.2.2 140 0x80000001 0x00F435
5.5.5.0 1.1.1.1 375 0x80000001 0x0043A5
23.0.0.0 2.2.2.2 823 0x80000002 0x0029F2
51.0.0.0 1.1.1.1 871 0x80000002 0x005272
Router Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 144 0x80000005 0x00A129 2
3.3.3.3 3.3.3.3 142 0x80000006 0x001B90 3
Summary Net Link States (Area 200)
Link ID ADV Router Age Seq# Checksum
1.1.1.0 2.2.2.2 172 0x80000003 0x005791
2.2.2.0 2.2.2.2 173 0x80000003 0x00B075
5.5.5.0 2.2.2.2 173 0x80000002 0x004B52
12.0.0.0 2.2.2.2 173 0x80000003 0x00D40C
51.0.0.0 2.2.2.2 173 0x80000003 0x005A1F
Type-7 AS External Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Tag
4.4.4.0 3.3.3.3 147 0x80000001 0x00A5BC 144
34.0.0.0 3.3.3.3 147 0x80000001 0x007AD1 144
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
4.4.4.0 2.2.2.2 139 0x80000001 0x005818 144
34.0.0.0 2.2.2.2 140 0x80000001 0x002D2D 144
R1#show ip os database 从区域0内的一台普通路由器上查看LSDB信息发现只有Type-5的信息
OSPF Router with ID (1.1.1.1) (Process ID 100)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 855 0x80000005 0x00CE93 3
2.2.2.2 2.2.2.2 158 0x80000005 0x00D483 3
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
3.3.3.0 2.2.2.2 126 0x80000001 0x00F435
5.5.5.0 1.1.1.1 360 0x80000001 0x0043A5
23.0.0.0 2.2.2.2 810 0x80000002 0x0029F2
51.0.0.0 1.1.1.1 855 0x80000002 0x005272
Router Link States (Area 100)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 364 0x80000008 0x00A771 2
5.5.5.5 5.5.5.5 15 0x80000007 0x009A4F 3
Summary Net Link States (Area 100)
Link ID ADV Router Age Seq# Checksum
1.1.1.0 1.1.1.1 370 0x80000002 0x004FE4
2.2.2.0 1.1.1.1 371 0x80000002 0x00AD43
3.3.3.0 1.1.1.1 126 0x80000001 0x009558
12.0.0.0 1.1.1.1 371 0x80000002 0x004F9C
23.0.0.0 1.1.1.1 371 0x80000002 0x00C916
Summary ASB Link States (Area 100)
Link ID ADV Router Age Seq# Checksum
2.2.2.2 1.1.1.1 153 0x80000001 0x00836C
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
4.4.4.0 2.2.2.2 126 0x80000001 0x005818 144
34.0.0.0 2.2.2.2 126 0x80000001 0x002D2D 144
R2#sho ip route 在NSSA区域的ABR发现ON1的路由信息,表示穿越NSSA区域的路由。
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
34.0.0.0/24 is subnetted, 1 subnets
O N1 34.0.0.0 [110/22] via 23.0.0.2, 00:08:20, FastEthernet0/0
51.0.0.0/24 is subnetted, 1 subnets
O IA 51.0.0.0 [110/128] via 12.0.0.1, 00:08:20, Serial1/0
1.0.0.0/24 is subnetted, 1 subnets
O 1.1.1.0 [110/65] via 12.0.0.1, 00:08:47, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
3.0.0.0/24 is subnetted, 1 subnets
O 3.3.3.0 [110/2] via 23.0.0.2, 00:08:20, FastEthernet0/0
4.0.0.0/24 is subnetted, 1 subnets
O N1 4.4.4.0 [110/22] via 23.0.0.2, 00:08:20, FastEthernet0/0
5.0.0.0/24 is subnetted, 1 subnets
O IA 5.5.5.0 [110/129] via 12.0.0.1, 00:08:21, Serial1/0
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0
完全末节NSSA 不允许ABR把类型3的传递给NSSA区域!!!!在ABR上需要输入no-summary的命令
R2(config-router)#area 200 nssa no-summary
R3#show ip os database ASBR查看LSA信息,没有发现类型3的信息。
OSPF Router with ID (3.3.3.3) (Process ID 100)
Router Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 1217 0x80000005 0x00A129 2
3.3.3.3 3.3.3.3 1213 0x80000006 0x001B90 3
Summary Net Link States (Area 200)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 2.2.2.2 109 0x80000001 0x00FC31
Type-7 AS External Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Tag
4.4.4.0 3.3.3.3 1218 0x80000001 0x00A5BC 144
34.0.0.0 3.3.3.3 1218 0x80000001 0x007AD1 144
R3#show ip route 查看路由表没有类型3的信息产生一条由ABR发送的默认路由。
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 23.0.0.1 to network 0.0.0.0
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial1/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
R 4.4.4.0 [120/1] via 34.0.0.2, 00:00:25, Serial1/0
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, FastEthernet0/0
O*IA 0.0.0.0/0 [110/2] via 23.0.0.1, 00:00:09, FastEthernet0/0
我们再查看RIP的路由信息:
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 34.0.0.1 to network 0.0.0.0
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
R 3.3.3.0 [120/1] via 34.0.0.1, 00:00:24, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
R 23.0.0.0 [120/1] via 34.0.0.1, 00:00:24, Serial1/0
R* 0.0.0.0/0 [120/1] via 34.0.0.1, 00:00:24, Serial1/0
从R4的RIP的角度去看,只学习到了NSSA区域中宣告的路由,其他的从AREA0转发过来就全部的被过滤掉了!!!!
从R5发布一条静态路由进入OSPF
R5(config)#ip route 20.20.20.0 255.255.255.0 null 0
R5(config)#router ospf 100
R5(config-router)#red static metric-type 1 tag 122 subnet
R3#sho ip os database 从ASBR 上查看LSDB发现没有这条路由,因为这条路由从R5进入到AREA0就变成类型3了,但是summary的信息是不给NSSA的。
OSPF Router with ID (3.3.3.3) (Process ID 100)
Router Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 481 0x80000006 0x009F2A 2
3.3.3.3 3.3.3.3 319 0x80000007 0x001991 3
Summary Net Link States (Area 200)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 2.2.2.2 1178 0x80000001 0x00FC31
Type-7 AS External Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Tag
4.4.4.0 3.3.3.3 319 0x80000002 0x00A3BD 144
34.0.0.0 3.3.3.3 319 0x80000002 0x0078D2 144
从R3(ASBR)上发布一条静态路由:
R3(config)#ip route 30.30.30.0 255.255.255.0 null 0
R3(config)#router ospf 100
R3(config-router)#red static sub metric-type 1 tag 166
这条路由通过NSSA区域以N路由的形式传递给ASBR R3,那么R3就再发布进入到了RIP,如何阻挡!!!
R4#sh 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 34.0.0.1 to network 0.0.0.0
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
R 2.2.2.0 [120/1] via 34.0.0.1, 00:00:23, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
R 3.3.3.0 [120/1] via 34.0.0.1, 00:00:23, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
R 23.0.0.0 [120/1] via 34.0.0.1, 00:00:23, Serial1/0
30.0.0.0/24 is subnetted, 1 subnets
R 30.30.30.0 [120/1] via 34.0.0.1, 00:00:23, Serial1/0
R* 0.0.0.0/0 [120/1] via 34.0.0.1, 00:00:23, Serial1/0
还是在R2上增加对NSSA区域的控制力度!!!!
R2(config-router)#area 200 nssa no-redistribution 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 34.0.0.1 to network 0.0.0.0
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
R 2.2.2.0 [120/1] via 34.0.0.1, 00:00:16, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
R 3.3.3.0 [120/1] via 34.0.0.1, 00:00:16, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
R 23.0.0.0 [120/1] via 34.0.0.1, 00:00:16, Serial1/0
R* 0.0.0.0/0 [120/1] via 34.0.0.1, 00:00:16, Serial1/0
R3(config-router)#do show ip os da
OSPF Router with ID (3.3.3.3) (Process ID 100)
Router Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 977 0x80000006 0x00BF0D 2
3.3.3.3 3.3.3.3 973 0x80000005 0x00BC06 2
Net Link States (Area 200)
Link ID ADV Router Age Seq# Checksum
23.0.0.2 3.3.3.3 976 0x80000001 0x007585
Summary Net Link States (Area 200)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 2.2.2.2 85 0x80000002 0x00FA32
Type-7 AS External Link States (Area 200)
Link ID ADV Router Age Seq# Checksum Tag
4.4.4.0 3.3.3.3 101 0x80000001 0x00A5BC 144
34.0.0.0 3.3.3.3 101 0x80000001 0x007AD1 144
各种类型路由表示符号:
O |
内部 |
OIA |
之间 |
OE1 |
外部,累加cost,default=20 |
OE2 |
外部,不累加cost,default=20 |
O*E1 ASBR产生的 |
Default route在ospf传递的时候产生的 |
O*E2 ASBR产生的 |
Default route在ospf传递的时候产生的 |
O*IA ABR产生的 |
末节区域或者次末节区域产生的。 |
O N2 |
穿越了NSSA区域的路由,不累加 |
O N1 |
穿越了NSSA区域的路由,进行累加cost |
R* |
OSPF通过NSSA来控制的行为 |
|
|