Lab_2 OSPF


一.OSPF邻接关系的建立流程... 2

二.NBMA下的OSPF. 20

三.虚链路... 28

四.认证... 31

五.外部汇总/ospf与rip的重发布... 36

 

 

 

一. OSPF邻接关系的建立流程

1.Down: 初始化状态.

ospf neighbor ospf neighbor设定 routemap_OSPF

2.Attempt: 只适于NBMA网络,在NBMA网络中邻居是手动指定的,在该状态下,路由器将使用HelloInterval取代PollInterval来发 送Hello包.

ospf neighbor ospf neighbor设定 routemap_数据库_02

3.Init: 表明在DeadInterval里收到了Hello包,但是2-Way通信仍然没有建立起来.

ospf neighbor ospf neighbor设定 routemap_链路_03

4.two-way: 双向会话建立.

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_04

5.ExStart: 信息交换初始状态,在这个状态下,本地路由器和邻居将建立Master/Slave关系,并确定DD Sequence Number,接口等级高的的成为Master。

ospf neighbor ospf neighbor设定 routemap_IP_05

.

6.Exchange: 信息交换状态,本地路由器向邻居发送数据库描述包,并且会发送LSR用于请求新的LSA

ospf neighbor ospf neighbor设定 routemap_IP_06

.

7.Loading: 信息加载状态,本地路由器向邻居发送LSR用于请求新的LSA

ospf neighbor ospf neighbor设定 routemap_数据库_07

.

8.Full: 完全邻接状态,这种邻接出现在Router LSA和Network LSA中

ospf neighbor ospf neighbor设定 routemap_数据库_08

ospf neighbor ospf neighbor设定 routemap_链路_09

Debug ip ospf packet

Debug ip ospf events

Debug ip ospf adj

Debug ip packet

状态

1.down 停止状态

2.init 初始状态 收到一个hello包后进入(形成邻居表)

3.two-way 双向状态 hello包中包含已知邻居列表 ,发现自己在hellow包中时,选举DR,BDR

4.exstart 准启动状态 挣选优先级(谁先说话/DR先发包)

5.exchange 交换状态 交换DBD(链路状态描述)分组僚属链路状态数据库(并返回ACK,进入下一个状态)

6.loading 加载状态 请求完整信息条目,发送LSU/返回LSUAck,进入下一个状态

7.full adjacency 全邻接状态 拓扑表同步(运行SPF/形成路由表/--转发数据库)

04:25:18: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up

//打开S0/0接口

04:25:18: OSPF: Interface Serial0/0 going Up

//OSPF进程启动

04:25:18: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 64, sending broad/multicast

//发送hello包组播 由于debug ip ospf packet 无法捕获到发送的hello包内容,所以这里无显示

04:25:18: OSPF: Build router LSA for area 0, router ID 1.1.1.1, seq 0x8000000F

//构建LAS

04:25:19: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up

R1#

04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 68, rcvd 0

04:25:25: OSPF: rcv. v:2 t:1 l:48 rid:2.2.2.2

aid:0.0.0.0 chk:F694 aut:0 auk: from Serial0/0

04:25:25: OSPF: Rcv hello from 2.2.2.2 area 0 from Serial0/0 12.1.1.2

//在S0/0收到来自12.1.1.2 的hello包,版本:2/类型:hello包/routerID:2.2.2.2/区域号:0/校验:F694/无验证/

04:25:25: OSPF: 2 Way Communication to 2.2.2.2 on Serial0/0, state 2WAY

//进入2way状态

04:25:25: OSPF: Send DBD to 2.2.2.2 on Serial0/0 seq 0x15C2 opt 0x42 flag 0x7 len 32

//通过S0/0发送DBD到2.2.2.2 ,序列号:0x15C2 flag 0x7,这是第一个DBD包,以后还会继续发,我为主

04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 52, sending broad/multicast

04:25:25: OSPF: End of hello processing

04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 52, rcvd 0

04:25:25: OSPF: rcv. v:2 t:2 l:32 rid:2.2.2.2

aid:0.0.0.0 chk:A337 aut:0 auk: from Serial0/0

04:25:25: OSPF: Rcv DBD from 2.2.2.2 on Serial0/0 seq 0xEBF opt 0x42 flag 0x7 len 32 mtu 1500 state EXSTART

//在S0/0上收到到来自2.2.2.2的DBD包 序列号:0xEBF flag 0x7,这是第一个DBD包,以后还会继续发,我为主,并进入准启动状态

04:25:25: OSPF: NBR Negotiation Done. We are the SLAVE

//经过一轮协商,发现我的routerid小于2.2.2.2所我为从

04:25:25: OSPF: Send DBD to 2.2.2.2 on Serial0/0 seq 0xEBF opt 0x42 flag 0x2 len 72

//给2.2.2.2发送一个DBD包确认,告诉他,我为从

04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 92, sending broad/multicast

04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 92, rcvd 0

04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 56, rcvd 0

04:25:25: OSPF: rcv. v:2 t:2 l:72 rid:2.2.2.2

aid:0.0.0.0 chk:2B5E aut:0 auk: from Serial0/0

04:25:25: OSPF: rcv. v:2 t:3 l:36 rid:2.2.2.2

aid:0.0.0.0 chk:F5CF aut:0 auk: from Serial0/0

04:25:25: OSPF: Rcv DBD from 2.2.2.2 on Serial0/0 seq 0xEC0 opt 0x42 flag 0x3 len 72 mtu 1500 state EXCHANGE

04:25:25: OSPF: Send DBD to 2.2.2.2 on Serial0/0 seq 0xEC0 opt 0x42 flag 0x0 len 32

04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 52, sending broad/multicast

04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 56, sending broad/multicast

04:25:25: OSPF: Database request to 2.2.2.2

04:25:25: OSPF: sent LS REQ packet to 12.1.1.2, length 12

//

04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 96, sending broad/multicast

04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 52, rcvd 0

04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 96, rcvd 0

04:25:25: OSPF: rcv. v:2 t:2 l:32 rid:2.2.2.2

aid:0.0.0.0 chk:A33B aut:0 auk: from Serial0/0

04:25:25: OSPF: rcv. v:2 t:4 l:76 rid:2.2.2.2

aid:0.0.0.0 chk:1373 aut:0 auk: from Serial0/0

04:25:25: OSPF: Rcv DBD from 2.2.2.2 on Serial0/0 seq 0xEC1 opt 0x42 flag 0x1 len 32 mtu 1500 state EXCHANGE

//双方交换DBD包,并确认,进入到EXCHANGE状态,向12.1.1.2放松链路状态请求(LS REQ),收到2.2.2.2来的LSU

04:25:25: OSPF: Exchange Done with 2.2.2.2 on Serial0/0

04:25:25: OSPF: Send DBD to 2.2.2.2 on Serial0/0 seq 0xEC1 opt 0x42 flag 0x0 len 32

//回复给2.2.2.2一个DBD包,确认双方数据库是否同步

04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 52, sending broad/multicast

04:25:25: OSPF: Synchronized with 2.2.2.2 on Serial0/0, state FULL

04:25:25: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Serial0/0 from LOADING to FULL, Loading Done

//进入全邻接状态

04:25:26: OSPF: Build router LSA for area 0, router ID 1.1.1.1, seq 0x80000010

04:25:26: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 108, sending broad/multicast

04:25:26: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 108, rcvd 0

04:25:26: OSPF: rcv. v:2 t:4 l:88 rid:2.2.2.2

aid:0.0.0.0 chk:3067 aut:0 auk: from Serial0/0

04:25:28: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 64, rcvd 0

04:25:28: OSPF: rcv. v:2 t:5 l:44 rid:2.2.2.2

aid:0.0.0.0 chk:1EF9 aut:0 auk: from Serial0/0

04:25:28: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 64, sending broad/multicast

04:25:28: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 68, sending broad/multicast

R1#

04:25:30: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 108, sending broad/multicast

04:25:30: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 108, rcvd 0

04:25:30: OSPF: rcv. v:2 t:4 l:88 rid:2.2.2.2

aid:0.0.0.0 chk:3063 aut:0 auk: from Serial0/0

R1#

04:25:33: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 64, rcvd 0

04:25:33: OSPF: rcv. v:2 t:5 l:44 rid:2.2.2.2

aid:0.0.0.0 chk:5C17 aut:0 auk: from Serial0/0

//同步数据库,并发送LSA确认

ospf neighbor ospf neighbor设定 routemap_数据库_10

ospf neighbor ospf neighbor设定 routemap_链路_11

ospf neighbor ospf neighbor设定 routemap_IP_12

ospf neighbor ospf neighbor设定 routemap_IP_13

ospf neighbor ospf neighbor设定 routemap_IP_14

ospf neighbor ospf neighbor设定 routemap_IP_15

ospf neighbor ospf neighbor设定 routemap_链路_16

ospf neighbor ospf neighbor设定 routemap_OSPF_17

ospf neighbor ospf neighbor设定 routemap_数据库_18

ospf neighbor ospf neighbor设定 routemap_IP_19

ospf neighbor ospf neighbor设定 routemap_IP_20

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_21

ospf neighbor ospf neighbor设定 routemap_链路_22

ospf neighbor ospf neighbor设定 routemap_IP_23

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_24

ospf neighbor ospf neighbor设定 routemap_OSPF_25

ospf neighbor ospf neighbor设定 routemap_数据库_26

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_27

ospf neighbor ospf neighbor设定 routemap_IP_28

ospf neighbor ospf neighbor设定 routemap_OSPF_29

ospf neighbor ospf neighbor设定 routemap_数据库_30

ospf neighbor ospf neighbor设定 routemap_IP_31

ospf neighbor ospf neighbor设定 routemap_数据库_32

ospf neighbor ospf neighbor设定 routemap_链路_33

1.1.点到点网络, 比如T1线路,是连接单独的一对路由器的网络,点到点网络上的有效邻居总是可以形成邻接关系的,在这种网络上,OSPF包的目标地址使用的是224.0.0.5,这个组播地址称为AllSPFRouters.

2.1.广播型网络,比如以太网,Token Ring和FDDI,这样的网络上会选举一个DR和BDR,DR/BDR的发送的OSPF包的目标地址为224.0.0.5,运载这些OSPF包的帧的目标MAC地址为0100.5E00.0005;而除了DR/BDR以外的OSPF包的目标地址为224.0.0.6,这个地址叫AllDRouters.

3.1.NBMA网络, 比如X.25,Frame Relay,和ATM,不具备广播的能力,因此邻居要人工来指定,在这样的网络上要选举DR和BDR,OSPF包采用unicast的方式

4.1.点到多点网络 是NBMA网络的一个特殊配置,可以看成是点到点链路的集合. 在这样的网络上不选举DR和BDR.

5.1.虚链接: OSPF包是以unicast的方式发送

在P-P网络,路由器是以组播方式将更新报文发送到组播地址224.0.0.5.

在P-MP和虚链路网络,路由器以单播方式将更新报文发送至邻接邻居的接口地址.

在广播型网络,DRother路由器只能和DR&BDR形成邻接关系,所以更新报文将发送到224.0.0.6,相应的DR以224.0.0.5泛洪LSA并且BDR只接收LSA,不会确认和泛洪这些更新,除非DR失效 在NBMA型网络,LSA以单播方式发送到DR BDR,并且DR以单播方式发送这些更新.

二.NBMA下的OSPF


ospf neighbor ospf neighbor设定 routemap_ospf neighbor_34

R1=center

R2=ISP

R3=Branch1

R4=Branch2

-----------------------------------------------------------------------------------

step1:

frame-relay switching

int s1/0

ISP(config-if)#encaps frame-relay

ISP(config-if)#no arp frame-relay

ISP(config-if)#no frame-relay inverse-arp

ISP(config-if)#frame-relay intf-type dce

ISP(config-if)#clo ra 64000

ISP(config-if)#frame-relay lmi-type ansi

ISP(config-if)#frame-relay route 102 int s1/1 201

ISP(config-if)#frame-relay route 103 int s1/2 301

ISP(config-if)#no shut

int s1/1

ISP(config-if)#encaps frame-relay

ISP(config-if)#no arp frame-relay

ISP(config-if)#no frame-relay inverse-arp

ISP(config-if)#frame-relay intf-type dce

ISP(config-if)#clo ra 64000

ISP(config-if)#frame-relay lmi-type ansi

ISP(config-if)#frame-relay route 201 int s1/0 102

ISP(config-if)#no shut

int s1/2

ISP(config-if)#encaps frame-relay

ISP(config-if)#no arp frame-relay

ISP(config-if)#no frame-relay inverse-arp

ISP(config-if)#frame-relay intf-type dce

ISP(config-if)#clo ra 64000

ISP(config-if)#frame-relay lmi-type ansi

ISP(config-if)#frame-relay route 301 int s1/0 103

ISP(config-if)#no shut

ospf neighbor ospf neighbor设定 routemap_IP_35

-----------------------------------------------------------------

#Central

step1:

Central(config)#int lo 0

Central(config-if)#ip add 1.1.1.1 255.255.255.0

Central(config-if)#ip ospf network point-to-point

Central(config)#int s1/1

Central(config-if)#encapsulation frame-relay

Central(config-if)#no arp frame-relay

Central(config-if)#no frame-relay inverse-arp

Central(config-if)#frame-relay lmi-type ansi

Central(config-if)#ip add 123.1.1.1 255.255.255.0

Central(config-if)#frame-relay map ip 123.1.1.2 102 broadcast

Central(config-if)#frame-relay map ip 123.1.1.3 103 broadcast

Central(config-if)#no shut

ospf neighbor ospf neighbor设定 routemap_数据库_36

step2:

router ospf 1

Central(config-router)#route-id 1.1.1.1

Central(config-router)#network 123.1.1.1 0.0.0.0 a 0

Central(config-router)#network 1.1.1.1 0.0.0.0 a0

ospf neighbor ospf neighbor设定 routemap_链路_37

step3:

Central(config)#router ospf 1

Central(config-router)#neighbor 123.1.1.2

Central(config-router)#neighbor 123.1.1.3

ospf neighbor ospf neighbor设定 routemap_数据库_38

---------------------------------------------------------------

#Branch1

step1:

Branch1(config)#int lo 0

Branch1(config-if)#ip add 2.2.2.2 255.255.255.0

Branch1(config-if)#ip ospf network point-to-point

Branch1l(config)#int s1/0

Branch1l(config-if)#encapsulation frame-relay

Branch1l(config-if)#no arp frame-relay

Branch1(config-if)#no frame-relay inverse-arp

Branch1(config-if)#frame-relay lmi-type ansi

Branch1(config-if)#ip add 123.1.1.2 255.255.255.0

Branch1(config-if)#frame-relay map ip 123.1.1.1 201 broadcast

Branch1(config-if)#frame-relay map ip 123.1.1.3 201 broadcast

Branch1(config-if)#no shut

ospf neighbor ospf neighbor设定 routemap_链路_39

step2:

router ospf 1

Branch1(config-router)#route-id 2.2.2.2

Branch1(config-router)#network 123.1.1.2 0.0.0.0 a 0

Branch1(config-router)#network 2.2.2.2 0.0.0.0 a0

ospf neighbor ospf neighbor设定 routemap_IP_40

step3:

Branch1(config)#int s1/0

Branch1(config)#ip ospf priority 0

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_41

----------------------------------------------------------------

#Branch2

setp1:

Branch2(config)#int lo 0

Branch2(config-if)#ip add 3.3.3.3 255.255.255.0

Branch2(config-if)#ip ospf network point-to-point

Branch2(config)#int s1/2

Branch2(config-if)#encapsulation frame-relay

Branch2(config-if)#no arp frame-relay

Branch2(config-if)#no frame-relay inverse-arp

Branch2(config-if)#frame-relay lmi-type ansi

Branch2(config-if)#ip add 123.1.1.3 255.255.255.0

Branch2(config-if)#frame-relay map ip 123.1.1.1 301 broadcast

Branch2(config-if)#frame-relay map ip 123.1.1.2 301 broadcast

Branch2(config-if)#no shut

ospf neighbor ospf neighbor设定 routemap_OSPF_42

step2:

router ospf 1

Branch1(config-router)#route-id 3.3.3.3

Branch1(config-router)#network 123.1.1.3 0.0.0.0 a 0

Branch1(config-router)#network 3.3.3.3 0.0.0.0 a0

ospf neighbor ospf neighbor设定 routemap_链路_43

step3:

Branch2(config)#int s1/2

Branch2(config)#ip ospf priority 0

ospf neighbor ospf neighbor设定 routemap_OSPF_44

此时如果no掉

branch1的 frame-relay map ip 123.1.1.3 201 broadcast

branch2的 frame-relay map ip 123.1.1.2 301 broadcast

就会出现有路由但无法PING通的现象,链路层封装失败

解决方案1

在Central上NO掉邻居

然后在S1/1上输入 ip ospf network point-to-mulitpoint

最好是在branch上也输入,不输入也行

解决方案2

子接口

为什么在NBMA上central没有指邻居为什么 还能收到Hello包

三.虚链路

ospf neighbor ospf neighbor设定 routemap_OSPF_45

ospf neighbor ospf neighbor设定 routemap_链路_46

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_47

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_48

ospf neighbor ospf neighbor设定 routemap_IP_49

R2(config)#router ospf 1

R2(config-router)#area 1 virtual-link 3.3.3.3

R2(config-router)#exit

R2(config)#exit

R3(config)#router ospf 1

R3(config-router)#area 1 virtual-link 2.2.2.2

R3(config-router)#exit

R3(config)#exit

命令中的area 2 指出有一条虚链路存在于区域2中。

virtual-link 172.16.255.9指出创建虚链路的对端R3路由器的router id

注意:使用router id,而不是接口ip.

ospf neighbor ospf neighbor设定 routemap_OSPF_50

ospf neighbor ospf neighbor设定 routemap_IP_51

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_52

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_53

ospf neighbor ospf neighbor设定 routemap_IP_54

四.认证

ospf neighbor ospf neighbor设定 routemap_数据库_55

查看R1和R2的路由表

ospf neighbor ospf neighbor设定 routemap_链路_56

ospf neighbor ospf neighbor设定 routemap_IP_57

ospf neighbor ospf neighbor设定 routemap_OSPF_58

ospf neighbor ospf neighbor设定 routemap_OSPF_59

明文认证

在R1上启用OSPF的明文认证

ospf neighbor ospf neighbor设定 routemap_数据库_60

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_61

在R2上启用OSPF的认证

R2(config-if)#s0/0

R2(config-if)#ip ospf authentication-key cisco

R2(config-if)#ip ospf authentication-

ospf neighbor ospf neighbor设定 routemap_数据库_62

基于MD5的密码接口认证

首先在R1和R2上关闭明文认证


R1(config-if)#ip ospf authentication message-digest

R1(config-if)#ip ospf message-digest-key 1 md5 cisco


R2(config-if)#ip ospf authentication message-digest

R2(config-if)#ip ospf message-digest-key 1 md5 cisco


ospf neighbor ospf neighbor设定 routemap_OSPF_63

区域认证

在R1上启用区域的明文认证

ospf neighbor ospf neighbor设定 routemap_OSPF_64

ospf neighbor ospf neighbor设定 routemap_IP_65

在R2上启用区域明文认证

ospf neighbor ospf neighbor设定 routemap_IP_66

MD5

R1(config)#router ospf 1

R1(config-router)#area 1 authentication message-digest

R1(config-router)#interface serial 0/0

R1(config-if)#ip ospf message-digest-key 1 md5 cisco

R2(config-if)#exit

R2(config)#

R2(config)#router ospf 1

R2(config-router)#area 1 authentication message-digest

R2(config-router)#exit

R2(config)#int s0/0

R2(config-if)#ip ospf message-digest-key 1 md5 cisco

R2(config-if)#exit

R2(config)#

当在接口出现两条md5的密码配置命令时,R2路由会发送两份不同的分组数据包。分别使用1和2的密码。

一旦新的密码2可以使用了,原的密码1就可以使用no命令取消。完成旧密码到新密码的迁移。

五.外部汇总/ospf与rip的重发布

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_67

查看路由表

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_68

ospf neighbor ospf neighbor设定 routemap_OSPF_69

ospf neighbor ospf neighbor设定 routemap_IP_70

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_71

在R3上配置重发布

ospf neighbor ospf neighbor设定 routemap_OSPF_72

查看路由表

ospf neighbor ospf neighbor设定 routemap_OSPF_73

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_74

ospf neighbor ospf neighbor设定 routemap_IP_75

ospf neighbor ospf neighbor设定 routemap_链路_76

在R3上进行外网的路由汇总

ospf neighbor ospf neighbor设定 routemap_链路_77

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_78

ospf neighbor ospf neighbor设定 routemap_ospf neighbor_79

ospf neighbor ospf neighbor设定 routemap_IP_80


转载于:https://blog.51cto.com/netpro/265988