Ospf 学习

首先先介绍一OSPF要点:

路由器在所有启 ospf 进程的接口发 hello OSPF 报头是固定的 (24 字节 ),LSA 也有自己的报头 , 封装 OSPF
HELLO协议的功能:
建立邻居关系保持邻居关系确定和邻居的双向关系用 DR BDR 的选举
路由器建立邻居关系的条件:
Area ID 区域号必须相 Authentication 密码必须相 Hello Dead intervals 计时器必须相 Stub area 如果配置 stub 2 台邻居路由器必须都要两端都要设置 Stub
Hello包内包含的字段
Hello 包的源路由 ID Hello 包源路由器接口的 地址 码路由器 优先级 , DR 选举 ( 默认 1 0 表示不 DR 选举 ) DR BDR 标记位 ,stub 标记 这里对 端路由器 ID, neighbor seen
网络类型:
Point to Point
点对点类型 , dr bdr 的选举 , ospf 包的 目标地址 224.0.0.5( ospf 路由器 组播地址 )
Broardcast
广播网络 , 以太网 , 令牌环网还 FDDI. 因为 访问 , 一台路由器的发的包 能被 所有路由器接 收。 广播类型网络 ,要进 dr bdr 选举, hello 包的 地址 224.0.0.5 DR BDR 的所有 数据 包也 224.0.0.5 Drother 224.0.0.6 将数据 包发 DR BDR
NBMA
NBMA不支广播如,ATMFrX.25 一台路由器发送的一不能同时所有的路由器接收到 这种类型上要进DRBDR
Point to multipoint
点对点类型 似不 dr bdr 选举, 数据 包用 组播传 送, 因为 点对点类型类 cisco 推荐此种 配置
下面介绍一下各种类型LSA
Type Code LSA Link-State IDLSID
1 Router LSA 路由器IDospf路由器都会产
2 Network LSA DR的接口地址DRBDR
3 Network summary LSA 网络号,ABR
4 ASBR summary LSA ASBR的路由ID
5 AS external LSA 外部网络
7 NSSA external LSA 外部网络
以下用例子和图示表示这几种类型LSA
Router_B#show ip ospf database 此命令查 ospf 链路数据 OSPF Router with ID ( 170.170.3.2 ) (Process ID 7 ) Router Link States (Area 0) 0 表示此路由器为主 , type1 lsa Link ID ADV Router Age Seq# Checksum Link count
170.170.3.2 170.170.3.2 17 0x80000002 0x8B6 1
170.170.8.4 170.170.8.4 217 0x80000003 0xAA02 1
170.170.13.3 170.170.13.3 218 0x80000002 0x5156 1
Net Link States (Area 0) type 2 LSA DR 传送过来 Link ID ADV Router Age Seq# Checksu m
170.170.3.3 170.170.13.3 18 0x80000002 0xA0B 2
Summary Net Link States (Area 0) type 3 LSA ,域间路 Link ID ADV Router Age Seq# Checksu m
170.170.7.0 170.170.8.4 240 0x80000001 0x6ED 0
Summary ASB Link States (Area 0) type 4 LSA ASBR 发过 Link ID ADV Router Age Seq# Checksum
170.170.11.6 170.170.8.4 129 0x80000001 0xF73 C
Type-5 AS External Link States type 5 LSA ASBR Link ID ADV Router Age Seq# Checksum Tag
200.200.200.0 170.170.11.6 135 0x80000001 0xE4FA 0
Router_B#
下面用图例来表示几LSA
Router LSA:就Type 1,所有路由器都能产
Network LSAType 2 LSADR产生发给所有Drother
Network Summary LSAType 3 ABR产生,此类用距离向量方法传送路由,一lsa传送一条路
ASBR Summary LSALSA 4ABR产生,下一跳ABR
AS External LSAType 5,下一跳ASBR,此类路由优先级低,为了防止环路,因为外部路由有可能是不可靠的。
下面介绍一ospf的配置命令:
首先 全局 配置
Step Command
1. router ospf process-id 启用路由进
2. network address wildcard-mask area area-id 启用路由进程的接口和区ID
Router_D: 路由 D ABR
interface ethernet 0
ip address 170.170.3.4 255.255.255. 0
interface serial 0
ip address 170.170.7.4 255.255.255. 0
router ospf 7
network 170.170.3.0 0.0.0.255 area 0 E0 ospf 并加入主
network 170.170.7.0 0.0.0.255 area 51 S0 ospf 加入 51
OSPF接口参数,下面的参数都是ospf接口模式输入
Command
ip ospf hello-interval seconds hello
ip ospf dead-interval seconds helloholdtimer
OSPF Hello Down 机判 间隔广 10 40 秒点对 10 40 NBMA 30 120
如果两端的 间隔 配置 不对就不会形 成邻接
Command
ip ospf priority number 设置路由器优先级,用DR选举,默认10表示不参加
Ospf 邻接的时 要选 DR BDR ,那么 首先 hello 种查 优先级 ,如果都相同的 话再 最高 RouterID 上面这条命令就 是设置 优先级
Command
ip ospf cost cost 设定接口成本
上面这条命令表示 设置接口成本,用 路由计 算。
下面 看一 下实例
Router_D#show ip ospf interface ethernet 0
Ethernet0 is up, line protocol is u p
Internet Address 170.170.3.4/24, Area 0
Process ID 7 , Router ID 170.170.8.4 , Network Type BROADCAST ,
Cost: 10
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) 170.170.13.3, Interface addres s
170.170.3. 3 Backup Designated router (ID) 170.170.8.4, Interfac e address 170.170.3. 4 Timer intervals configured, Hello 10 , Dead 40 , Wait 40 ,
Retransmit 5 Hello due in 00:00:0 8 Index 1/1, flood queue length 0 Next 0x0(0)/0x0(0 ) Last flood scan length is 0, maximum is 3 Last flood scan time is 0 msec, maximum is 0 mse c Neighbor Count is 2, Adjacent neighbor count is 2
Adjacent with neighbor 170.170.3. 2 Adjacent with neighbor 170.170.13.3 (Designated Router ) Suppress hello for 0 neighbor(s )
Router_D#
的网络类型ospf
NBMA
Command
neighbor ip-address [priority number] [poll-interval seconds] 手工定邻居
如果 网络类型 NBMA 因为不支 广播 ,那么 要用 此命令 手工 定邻居 IOS 配置 为点对点 点对多点类型 ,所 以这条命令 很少 用了
点对点 字接口 类型:
这种类型 物理 端口配置成 多个 接口 模式 每个 接口是一 单独 每个 接口都 为点对点 模式 就不会 DR 的选举
Router_F:
interface Serial 2 no ip addres s encapsulation frame-rela y frame-relay lmi-type ans i
!
interface Serial2.7 point-to-poin t ip address 170.170.11.6 255.255.255. 0 frame-relay interface-dlci 10 1
! interface Serial2.8 point-to-poin t ip address 170.170.10.6 255.255.255. 0
frame-relay interface-dlci 10 3
router ospf 7 network 170.170.11.0 0.0.0.255 area 0 network 170.170.10.0 0.0.0.255 area 0
Router_G:
interface Serial 0 no ip addres s encapsulation frame-rela y frame-relay lmi-type ANS I
!
interface Serial0.6 point-to-poin t ip address 170.170.11.7 255.255.255. 0 frame-relay interface-dlci 11 0
router ospf 7 network 170.170.11.0 0.0.0.255 area 0
Command
ip ospf network {broadcast | non-broadcast | {point-to-multipoint [non-broadcast] }} 改变网络类型
这条命令 是用 ospf 接口 类型
点对多点类型:
是邻居在一 DR BDR 的选
Router_E:
interface Serial 1 ip address 170.170.9.5 255.255.255. 0 no ip mroute-cach e encapsulation frame-rela y
ip ospf network point-to-multipoint
frame-relay map ip 170.170.9.7 121 broadcas t frame-relay map ip 170.170.9.8 123 broadcas t router ospf 7 network 170.170.9.0 0.0.0.255 area 0
Router_G:
interface Serial 0
no ip addres s
encapsulation frame-rela y
frame-relay lmi-type ANS I
!
interface Serial0.5 multipoin t
ip address 170.170.9.7 255.255.255. 0
ip ospf network point-to-multipoint
frame-relay map ip 170.170.9.5 112 broadcas t router ospf 7 network 170.170.9.0 0.0.0.255 area 0
点对多点还 是,所有的邻居都 会产生 邻居的 路由
Router_E#show ip rout e
Codes: C -connected, S -static, I -IGRP, R -RIP, M -mobile ,
B - BG P
D -EIGRP, EX -EIGRP external, O -OSPF, IA -OSPF inte r
are a
N1 -OSPF NSSA external type 1, N2 -OSPF NSSA external typ e
2
E1 -OSPF external type 1, E2 -OSPF external type 2, E -
EG P
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * -
candidate defaul t
U - per-user static route, o - OD R
Gateway of last resort is not se t 170.170.0.0/16 is variably subnetted, 5 subnets, 2 mask s
O 170.170.9.8/32 [110/64] via 170.170.9.8, 00:07:01, Serial1
C 170.170.9.0/24 is directly connected, Serial 1
O 170.170.9.7/32 [110/64] via 170.170.9.7, 00:07:01, Serial1
Router_E#
邻居 间就不 Frame Relay map
下面 DR 情况
Router_E#show ip ospf interface serial 1
Serial1 is up, line protocol is u p
Internet Address 170.170.9.5/24, Area 0
Process ID 7, Router ID 170.170.9.5, Network Typ e
POINT_TO_MULTIPOINT, Cost: 6 4
Transmit Delay is 1 sec, State POINT_TO_MULTIPOINT ,
Timer intervals configured, Hello 30, Dead 120, Wait 120 ,
Retransmit 5
Hello due in 00:00:0 4
Neighbor Count is 2, Adjacent neighbor count is 2
Adjacent with neighbor 170.170.12. 8
Adjacent with neighbor 170.170.12. 7
Suppress hello for 0 neighbor(s) Router_E# DR BDR
配置路由聚合
聚合 ABR ASBR 的, 聚合可 减小 路由 降低 路由 抖动 路由 聚合 2 l 路由 l 外部 路由 聚合
首先看域间路由聚合
Command
area area-id range address mask 聚合地址area-id是要聚合的那id
路由 B 和路由 D ABR ,中 area0 主干 在路由 B
router ospf 7 network 170.170.1.0 0.0.0.255 area 5 1 network 170.170.3.0 0.0.0.255 area 0
area 1 range 172.16.128.0 255.255.224.0 area 1 的路由,发 area0
外部路由聚合External route
Command
summary-address address mask 定要聚合外部地址
A ASBR ,要 将外部 172.16.128.0/24 �C 172.16.159.0/24 聚合 area 0 主干 要配置
router ospf 7
summary-address 172.16.128.0 255.255.224.0
redistribute static subnets
network 170.170.1.0 0.0.0.255 area 51
聚合 外部 路由要 summary-address 不能 area range 聚合
Stub AreasToally Stubby Areas
stub Type 5 类型 Lsa ,也 外部 路由,接 其他 Lsa Toally 缺省 路由和域 路由, 外部
Command
area area-id stub [no-summary] stubToally stub
是看幅图 路由A外部路由主干,那么如果Router F配置Stub域,看看还能不能收到那些外部路由
Router_D:
router ospf 7 network 170.170.3.0 0.0.0.255 area 0 network 170.170.7.0 0.0.0.255 area 1
area 1 stub
Router_F:
router ospf 7 network 170.170.7.0 0.0.0.255 area 1
area 1 stub
我们 看一 路由 F 的路由
Router_F#sh ip rout e
Codes: C -connected, S -static, I -IGRP, R -RIP, M -mobile ,
B - BG P
D -EIGRP, EX -EIGRP external, O -OSPF, IA -OSPF inte r
are a
N1 -OSPF NSSA external type 1, N2 -OSPF NSSA external typ e
2
E1 -OSPF external type 1, E2 -OSPF external type 2, E -
EG P
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * -
candidate defaul t
U - per-user static route, o - OD R
Gateway of last resort is 170.170.7.4 to network 0.0.0. 0 170.170.0.0/24 is subnetted, 3 subnet s OIA170.170.1.0[110/138]via170.170.7.4, 00:02:42,Serial 0
O IA 170.170.3.0 [110/74] via 170.170.7.4, 00:02:42, Serial 0
C 170.170.7.0 is directly connected, Serial 0
O*IA 0.0.0.0/0 [110/65] via 170.170.7.4, 00:02:42, Serial 0
Router_F#
了域 缺省 路由之 外部 路由
下来 area 1 在配置 Toally Stub
Router_D:
router ospf 7 network 170.170.3.0 0.0.0.255 area 0 network 170.170.7.0 0.0.0.255 area 1
area 1 stub no-summary
Router_F:
router ospf 7 network 170.170.7.0 0.0.0.255 area 1
area 1 stub no-summary
在看看路由 F 的路由
Router_F#sh ip rout e
Codes: C -connected, S -static, I -IGRP, R -RIP, M -mobile ,
B - BG P
D -EIGRP, EX -EIGRP external, O -OSPF, IA -OSPF inte r
are a
N1 -OSPF NSSA external type 1, N2 -OSPF NSSA external typ e
2
E1 -OSPF external type 1, E2 -OSPF external type 2, E -
EG P
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * -
candidate defaul t
U - per-user static route, o - OD R
Gateway of last resort is 170.170.7.4 to network 0.0.0. 0
170.170.0.0/24 is subnetted, 1 subnet s
C 170.170.7.0 is directly connected, Serial 0
O*IA 0.0.0.0/0 [110/65] via 170.170.7.4, 00:00:00, Serial0 Router_F# 有一 缺省 路由了, LSA Type 3 的也 有了
NSSA Area Not-So Stubby Area
Command
area area-id nssa [no-redistribution] [default-information-originate] 配置NSSA
Area 51 配置 NSSA 模式 ,路由 A 外部 路由 Lsa Type 7 往主干 ,路由 B Type 7 Type 5
Router_A:
router ospf 7 redistribute static subnet s network 170.170.1.0 0.0.0.255 area 5 1
area 51 nssa
! ip route 172.16.128.0 255.255.255.0 Serial 1 ip route 172.16.129.0 255.255.255.0 Serial 1 ip route 172.16.130.0 255.255.255.0 Serial 1
Router_B:
router ospf 7 network 170.170.1.0 0.0.0.255 area 5 1 network 170.170.3.0 0.0.0.255 area 0
area 51 nssa
看看路由 B 的路由 到类 7 的路
Router_B# sh ip rout e Codes: C -connected, S -static, I -IGRP, R -RIP, M -mobile , B - BG P
D -EIGRP, EX -EIGRP external, O -OSPF, IA -OSPF inte r
are a
N1 -OSPF NSSA external type 1, N2 -OSPF NSSA external typ e
2
E1 -OSPF external type 1, E2 -OSPF external type 2, E -
EG P
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * -
candidate defaul t
U -per-user static route, o -ODR, P -periodic downloade d
static rout e
T - traffic engineered rout e
Gateway of last resort is not se t
170.170.0.0/24 is subnetted, 3 subnet s
C 170.170.1.0 is directly connected, Serial 0
C 170.170.3.0 is directly connected, Ethernet 0
O IA 170.170.7.0 [110/74] via 170.170.3.4, Ethernet 0
172.16.0.0/24 is subnetted, 3 subnet s
O N2 172.16.128.0 [110/20] via 170.170.1.1, Serial0 O N2 172.16.129.0 [110/20] via 170.170.1.1, Serial0 O N2 172.16.130.0 [110/20] via 170.170.1.1, Serial0
Router_B #
看看路由 B 数据 Type 7 LSA
Router_B#show ip ospf databas e OSPF Router with ID (170.170.3.2) (Process ID 7 )
Router Link States (Area 0 ) Link ID ADV Router Age Seq# Checksum Link coun t
170.170.3.2 170.170.3.2 1395 0x8000002A 0xB6DD 1
170.170.8.4 170.170.8.4 973 0x80000029 0x5433 1
Net Link States (Area 0 ) Link ID ADV Router Age Seq# Checksu m
170.170.3.2 170.170.3.2 1773 0x80000027 0x228 1
Summary Net Link States (Area 0 ) Link ID ADV Router Age Seq# Checksu m
170.170.1.0 170.170.3.2 1773 0x80000027 0x939 2
170.170.7.0 170.170.8.4 974 0x80000027 0x22F 6
Router Link States (Area 51 ) Link ID ADV Router Age Seq# Checksum Link coun t
170.170.3.2 170.170.3.2 1378 0x8000002A 0x5F4C 2
170.170.13.1 170.170.13.1 1381 0x80000038 0x3D59 2
Summary Net Link States (Area 51 ) Link ID ADV Router Age Seq# Checksu m
170.170.3.0 170.170.3.2 1398 0x8000002A 0xFE5 2
170.170.7.0 170.170.3.2 1398 0x80000028 0x59B 5
Type-7 AS External Link States (Area 51)
Link ID ADV Router Age Seq# Checksum Ta g
172.16.128.0 170.170.13.1 124 0x80000002 0xFF9D 0
172.16.129.0 170.170.13.1 125 0x80000002 0xF4A7 0
172.16.130.0 170.170.13.1 125 0x80000002 0xE9B1 0
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Ta g
172.16.128.0 170.170.3.2 1367 0x80000001 0xD6DA 0
172.16.129.0 170.170.3.2 1367 0x80000001 0xCBE4 0
172.16.130.0 170.170.3.2 1367 0x80000001 0xC0EE 0
Router_B#  

你可能感兴趣的:(职场,报文,休闲,ospf)