实施拓扑 1.OSPF基础(开放最短路径优先) 考试(LAB、面试)、工作(面试) 1.1基础配置: [R6]ospf //进入OSPF进程,默认进程1 [R6-ospf-1]area 0 //创建区域,区域0 [R6-ospf-1]area 56 //创建区域,区域56 [R6-ospf-1-area-0.0.0.0]network 10.1.56.0 ? IP_ADDR<X.X.X.X> OSPF wild card bits //OSPF的通配符掩码,通配符掩码~~范围。二进制的0=固定,不做任何变化; 和1=可以任意变化 [R6-ospf-1-area-0.0.0.56]network 10.1.56.0 0.0.0.255//含义为:①10.1.56.0/24这个范围内的设备都运行OSPF,②同时把10.1.56.0/24这个网络通告到OSPF去,让其他设备学习 [R6-LoopBack0]ospf enable area 56 //等同于上面的network 如果接口下实施OSPF,不要忘记在进程创建区域 总结一点:先创建区域,然后接口下直接配置OSPF

[R5-LoopBack0]ip address 10.1.5.5 24 //配置了24的地址 [R5-LoopBack0]ospf [R5-ospf-1-area-0.0.0.0]network 10.1.5.5 0.0.0.0 //可行么?通配掩码,范围:只有10.1.5.5 运行了OSPF 请在相关设备自行配置

1.2 OSPF基础验证命令: [R5]display ospf int //查看运行OSPF的接口

     OSPF Process 1 with Router ID 10.1.5.5
             Interfaces 

Area: 0.0.0.0 (MPLS TE not enabled) IP Address Type State Cost Pri DR BDR 10.1.5.5 P2P P-2-P 0 1 0.0.0.0 0.0.0.0

Area: 0.0.0.56 (MPLS TE not enabled) IP Address Type State Cost Pri DR BDR 10.1.56.5 P2P P-2-P 48 1 0.0.0.0 0.0.0.0 [R5]display ospf peer brief //查看基本的OSPF邻居状态

     OSPF Process 1 with Router ID 10.1.5.5
              Peer Statistic Information

Area Id Interface Neighbor id State
0.0.0.56 Serial2/0/0 10.1.6.6 Full

[R5]display ospf lsdb //验证基本的OSPF数据库

     OSPF Process 1 with Router ID 10.1.5.5
             Link State Database 

                     Area: 0.0.0.0

Type LinkState ID AdvRouter Age Len Sequence Metric Router 10.1.5.5 10.1.5.5 176 36 80000001 0 Sum-Net 10.1.56.0 10.1.5.5 176 28 80000001 48 Sum-Net 10.1.6.6 10.1.5.5 176 28 80000001 48

                     Area: 0.0.0.56

Type LinkState ID AdvRouter Age Len Sequence Metric Router 10.1.5.5 10.1.5.5 621 48 80000002 48 Router 10.1.6.6 10.1.6.6 622 60 80000004 0 Sum-Net 10.1.5.5 10.1.5.5 176 28 80000001 0

[R5]dis ip routing-table protocol ospf //验证通过OSPF得到的路由信息 Route Flags: R - relay, D - download to fib

Public routing table : OSPF Destinations : 1 Routes : 1

OSPF routing table status : <Active> Destinations : 1 Routes : 1

Destination/Mask Proto Pre Cost Flags NextHop Interface

   10.1.6.6/32  OSPF    10   48          D   10.1.56.6       Serial2/0/0

OSPF routing table status : <Inactive> Destinations : 0 Routes : 0 <R6>ping -a 10.1.6.6 10.1.5.5 PING 10.1.5.5: 56 data bytes, press CTRL_C to break Reply from 10.1.5.5: bytes=56 Sequence=1 ttl=255 time=30 ms Reply from 10.1.5.5: bytes=56 Sequence=2 ttl=255 time=20 ms Reply from 10.1.5.5: bytes=56 Sequence=3 ttl=255 time=20 ms

1.3 关于RID AS,BGP的AS,其他协议称之为域(RIP域、OSPF的域、中间系统到中间系统的域) RID,路由器ID,来唯一的标识运行某种协议的标识 <R6>router id 0.0.6.6 //对路由协议设置“泛泛”的RID [R6]ospf 1 router-id 6.6.6.6 //专门针对OSPF 进程1(不同进程有不同的ID)指定路由器ID Info: The configuration succeeded. You need to restart the OSPF process to validate the new router ID. 强烈建议手工配置RID

1.4 OSPF的第一种报文:Hello(发现建立和维护邻居) 发现过程:224.0.0.5自动发现邻居,ALLSPF ROUTER 建立过程:相互认可(时间、区域、认证、掩码、RID) 维护过程:定期的发送Hello Hello相关的邻居状态 DOWN(attempt)、INIT、2-WAY(代表了邻居-neighbor建立) 邻接(adjancy)

1.5 OSPF手工发现邻居 FR(frame relay,帧中继)环境的物理接口,默认在OSPF中是一种NBMA(非广播多路访问)接口 容易犯的错误:1)进程或者接口没有创建、使能特定区域 2)直连通信的前提下相互手工指定邻居 单播发送Hello R4不能和R5直连通信 [R1-ospf-1]peer 10.1.1.4 [R1-ospf-1]peer 10.1.1.5 [R4-ospf-1]peer 10.1.1.1 [R5-ospf-1]peer 10.1.1.1 Dec 9 2017 15:30:12-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[0]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=4.1.1.10, NeighborEvent=Start, NeighborPreviousState=Down, NeighborCurrentState=Attempt) 待解决:路由问题和数据通信问题 解决方案:1)控制DR(指定路由器) 2)改变OSPF的网络类型 1.6 邻居关系拍错 (TAC) dis ospf error 1) <SW3>dis ospf error

     OSPF Process 1 with Router ID 10.1.15.3
             OSPF error statistics 

General packet errors: 0 : IP: received my own packet 7 : Bad packet 0 : Bad version 0 : Bad checksum 0 : Bad area id 0 : Drop on unnumbered interface 0 : Bad virtual link 0 : Bad authentication type 0 : Bad authentication key 0 : Packet too small 0 : Packet size > ip length 0 : Transmit error 0 : Interface down 0 : Unknown neighbor 0 : Bad net segment 0 : Extern option mismatch 0 : Router id confusion

HELLO packet errors: 7 : Netmask mismatch //掩码不匹配,在多点接入(以太网、NBMA...)网络,不能建立ospf peer 2)同一链路要求运行OSPF的同一个区域 ospf 1 router-id 6.6.6.6 area 0.0.0.0 area 0.0.0.56 network 10.1.56.0 0.0.0.255

interface Serial2/0/0 link-protocol ppp ip address 10.1.56.6 255.255.255.0 ospf enable 1 area 0.0.0.6 请问s2/0/0到底在区域多少? A a6 B a0 C NONE 答案C

[R6]dis ospf error

     OSPF Process 1 with Router ID 6.6.6.6
             OSPF error statistics 

General packet errors: 0 : IP: received my own packet 0 : Bad packet 0 : Bad version 0 : Bad checksum 2 : Bad area id //同一链路接口上配置了不同的区域ID

第一天:过滤;坚持动手;第一遍能学到40%! 作业: 1.区域0通过手工当时成功创建邻居 2.完成区域15、35、56的邻居 hcnp@qytang.com