1、(最新整理)华为eNSP配置实例10OSPF单区域路由配置2021/7/261十十.OSPF单区域路由配单区域路由配置置2021/7/262 2场景场景 你是公司的网络管理员。现在公司的网络准备使用OSPF协议来进行路由信息的传递。规划网络中所有路由器属于OSPF的区域0实际使用中需要向OSPF发布默认路由,此外你也希望通过这次部署了解DR/BDR选举的机制。2021/7/263 3网络拓扑10.0.12.2/2410.0.12.1/24Loopback 010.0.2.2/24Loopback 010.0.1.1/24Loopback 010.0.3.3/2410.0.23.2/2410.0
2、.23.1/24注:loopback不是一个设备,是在路由器里设置出来的Loopback 2172.0.16.1/242021/7/264 4步骤一步骤一.基本配置与基本配置与IP编址编址R1的基本配置undo ter monsysHuaweisysname R1R1int s0/0/0R1-Serial0/0/0ip addr 10.0.12.1 24R1-Serial0/0/0undo shutR1-Serial0/0/0int loopback 0R1-LoopBack0ip addr 10.0.1.1 242021/7/265 5R2的基本配置undo ter monsysHuawei
3、sysname R2R2int s0/0/0R2-Serial0/0/0ip addr 10.0.12.2 24R2-Serial0/0/0undo shutR2-Serial0/0/0int s0/0/1R2-Serial0/0/1ip addr 10.0.23.2 24R2-Serial0/0/1undo shutR2-Serial0/0/1int loopback 0R2-LoopBack0ip addr 10.0.2.2 242021/7/266 6R3的基本配置undo ter monsysHuaweisysname R3R3int s0/0/1R3-Serial0/0/1ip ad
4、dr 10.0.23.1 24R3-Serial0/0/1undo shutR3-Serial0/0/1int loopback 0R3-LoopBack0ip addr 10.0.3.3 242021/7/267 7步骤二步骤二.OSPF配置配置 定义R1的Loopback0接口地址10.0.1.1作为R1的Router ID,使用默认的OSPF进程号1,将10.0.12.0/24、10.0.1.0/24网段定义到OSPF区域0。R1ospf 1 router-id 10.0.1.1 设置OSPF进程号1,路由器的身份编号(ID)为10.0.1.1R1-ospf-1area 0 设置ospf
5、的区域0R1-ospf-1-area-0.0.0.0network 10.0.1.0 0.0.0.255 将网络10.0.1.0 通告给OSPF协议,0.0.0.255是该网络的反掩码R1-ospf-1-area-0.0.0.0network 10.0.12.0 0.0.0.255R1-ospf-1-area-0.0.0.0quitR1-ospf-1解释:同一个路由器可以开启多个OSPF进程,默认进程号为1,由于进程号只具有本地意义,所以同一路由域的不同路由器可以使用相同或不同的OSPF进程号;network命令后面需使用反掩码。2021/7/268 8定义R2的Loopback0接口地址10
6、.0.2.2作为R2的Router ID,配置使用OSPF进程号10,将10.0.12.0/24、10.0.23.0/24和10.0.2.0/24两个网段定义到OSPF区域0。R2ospf 10 router-id 10.0.2.2R2-ospf-10area 0R2-ospf-10-area-0.0.0.0network 10.0.2.0 0.0.0.255R2-ospf-10-area-0.0.0.0network 10.0.12.0 0.0.0.255R2-ospf-10-area-0.0.0.0network 10.0.23.0 0.0.0.255R2-ospf-10-area-0.0
7、.0.0quitR2-ospf-10quit2021/7/269 9定义R3的Loopback0接口地址10.0.3.3作为R3的Router ID,配置使用OSPF进程号100,将10.0.23.0/24和10.0.3.0/24两个网段定义到OSPF区域0。R3ospf 100 router-id 10.0.3.3 R3-ospf-100area 0R3-ospf-100-area-0.0.0.0network 10.0.3.0 0.0.0.255R3-ospf-100-area-0.0.0.0network 10.0.23.0 0.0.0.255R3-ospf-100-area-0.0.0
8、.0quitR3-ospf-100quitR32021/7/261010步骤三步骤三.检查路由无误检查路由无误查看R1、R2和R3的路由表,确认各路由器已经学习到以下红色突出显示部分的RIP路由。R1display ip routing-tableRoute Flags:R-relay,D-download to fib-10.0.1.0/24 Direct 0 0 D 10.0.1.1 LoopBack0 10.0.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0 10.0.2.2/32 OSPF 10 1562 D 10.0.12.2 Serial0/0/0
9、10.0.3.3/32 OSPF 10 3124 D 10.0.12.2 Serial0/0/0 10.0.12.0/24 Direct 0 0 D 10.0.12.1 Serial0/0/0 10.0.12.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/0 10.0.12.2/32 Direct 0 0 D 10.0.12.2 Serial0/0/0 10.0.23.0/24 OSPF 10 3124 D 10.0.12.2 Serial0/0/0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/
10、32 Direct 0 0 D 127.0.0.1 InLoopBack02021/7/261111查看R2的路由表R2dis ip routDestination/Mask Proto Pre Cost Flags NextHop Interface 10.0.1.1/32 OSPF 10 1562 D 10.0.12.1 Serial0/0/0 10.0.2.0/24 Direct 0 0 D 10.0.2.2 LoopBack0 10.0.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0 10.0.3.3/32 OSPF 10 1562 D 10.0.23.
11、1 Serial0/0/1 10.0.12.0/24 Direct 0 0 D 10.0.12.2 Serial0/0/0 10.0.12.1/32 Direct 0 0 D 10.0.12.1 Serial0/0/0 10.0.12.2/32 Direct 0 0 D 127.0.0.1 Serial0/0/0 10.0.23.0/24 Direct 0 0 D 10.0.23.2 Serial0/0/1 10.0.23.1/32 Direct 0 0 D 10.0.23.1 Serial0/0/1 10.0.23.2/32 Direct 0 0 D 127.0.0.1 Serial0/0/
12、1 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack02021/7/261212查看R3的路由表R3dis ip routRoute Flags:R-relay,D-download to fib-10.0.1.1/32 OSPF 10 3124 D 10.0.23.2 Serial0/0/1 10.0.2.2/32 OSPF 10 1562 D 10.0.23.2 Serial0/0/1 10.0.3.0/24 Direct 0 0 D 10.0.3.3
13、LoopBack0 10.0.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack0 10.0.12.0/24 OSPF 10 3124 D 10.0.23.2 Serial0/0/1 10.0.23.0/24 Direct 0 0 D 10.0.23.1 Serial0/0/1 10.0.23.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/1 10.0.23.2/32 Direct 0 0 D 10.0.23.2 Serial0/0/1 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.
14、0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack02021/7/261313用ping来测试连通性ping 10.0.1.1 PING 10.0.1.1:56 data bytes,press CTRL_C to break Reply from 10.0.1.1:bytes=56 Sequence=1 ttl=254 time=50 ms Reply from 10.0.1.1:bytes=56 Sequence=2 ttl=254 time=50 ms Reply from 10.0.1.1:bytes=56 Sequence=3 ttl=254 tim
15、e=60 ms Reply from 10.0.1.1:bytes=56 Sequence=4 ttl=254 time=50 ms Reply from 10.0.1.1:bytes=56 Sequence=5 ttl=254 time=60 ms -10.0.1.1 ping statistics-5 packet(s)transmitted 5 packet(s)received 0.00%packet loss round-trip min/avg/max=50/54/60 ms2021/7/261414步骤四步骤四.查看其他信息查看其他信息使用display ip routing-t
16、able protocol ospf命令可以查看通过OSPF学到的路由,同样可以在R2和R3上进行相同操作。dis ip rout protocol ospfRoute Flags:R-relay,D-download to fib-Public routing table:OSPF Destinations:3 Routes:3 OSPF routing table status:Destinations:3 Routes:3Destination/Mask Proto Pre Cost Flags NextHop Interface 10.0.2.2/32 OSPF 10 1562 D 1
17、0.0.12.2 Serial0/0/0 10.0.3.3/32 OSPF 10 3124 D 10.0.12.2 Serial0/0/0 10.0.23.0/24 OSPF 10 3124 D 10.0.12.2 Serial0/0/0OSPF routing table status:Destinations:0 Routes:02021/7/261515使用display ospf peer命令查看OSPF邻居状态。display ospf peer OSPF Process 10 with Router ID 10.0.2.2 Neighbors Area 0.0.0.0 interf
18、ace 10.0.12.2(Serial0/0/0)s neighbors Router ID:10.0.12.1 Address:10.0.12.1 State:Full Mode:Nbr is Master Priority:1 DR:None BDR:None MTU:0 Dead timer due in 34 sec Retrans timer interval:5 Neighbor is up for 00:21:43 Authentication Sequence:0 续下页2021/7/261616接上页Neighbors Area 0.0.0.0 interface 10.0
19、.23.2(Serial0/0/1)s neighbors Router ID:10.0.3.3 Address:10.0.23.1 State:Full Mode:Nbr is Master Priority:1 DR:None BDR:None MTU:0 Dead timer due in 29 sec Retrans timer interval:5 Neighbor is up for 00:21:32 Authentication Sequence:0 使用display ospf peer命令可以显示邻居的详细信息,由上输出可以看出,R2有两个邻居R1(Router ID:10.
20、0.12.1)和R2(Router ID:10.0.3.3),而且邻居状态都是完全邻接状态。2021/7/261717也可以使用display ospf peer brief命令以更简洁的方式查看邻居状态。dis ospf peer brief OSPF Process 10 with Router ID 10.0.2.2 Peer Statistic Information-Area Id Interface Neighbor id State 0.0.0.0 Serial0/0/0 10.0.12.1 Full 0.0.0.0 Serial0/0/1 10.0.3.3 Full 2021/
21、7/261818步骤五步骤五.OSPF缺省路由发布及验证缺省路由发布及验证 1.先给R3增加1个loopback接口,设置IP为172.0.16.1/24 R3 int loopback 2R3-LoopBack2ip addr 172.0.16.1 242.在R3上配置默认路由并发布到OSPF域内。R3ip route-static 0.0.0.0 0 LoopBack 2 一条默认路由,0.0.0.0表示到任何网络,后边的0是反掩码,这条默认路由说明默认情况下到其他网络都通过接口loopback2发送。3.默认路由发布R3ospf 100 R3-ospf-100default-route-
22、advertise 将默认路由发布到OSPF域内2021/7/261919在R2上可以看到这条路由已经被学到R2dis ip routRoute Flags:R-relay,D-download to fib-Routing Tables:Public Destinations:13 Routes:13 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 O_ASE 150 1 D 10.0.23.1 Serial0/0/1 10.0.1.1/32 OSPF 10 1562 D 10.0.12.1 Serial0/0/0 10.0.2.0/24 Direct 0 0 D 10.0.2.2 LoopBack0 10.0.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0 10.0.3.3/32 OSPF 10 1562 D 10.0.23.1 Serial0/0/1 10.0.12.0/24 Direct 0 0 D 10.0.12.2 Serial0/0/02021/7/2620202021/7/262121