【汇总】华为路由交换由浅入深系列
掌握目标
二、OSPF 单区域配置
三、修改OSPF Hello和Dead时间
四、OSPF重分布默认路由
五、OSPF DR/BDR选举
六、配置OSPF多区域
七、OSPF直连路由重分布
八、配置OSPF认证
拓扑一
一、基本配置如下:
R1:
interface Serial1/0/0
ip address 10.0.12.1 255.255.255.0
interface GigabitEthernet0/0/0
ip address 10.0.13.1 255.255.255.0
interface LoopBack0
ip address 10.0.1.1 255.255.255.0
R2:
interface Serial1/0/0
ip address 10.0.12.2 255.255.255.0
interface LoopBack0
ip address 10.0.2.2 255.255.255.0
R3:
interface GigabitEthernet0/0/0
ip address 10.0.13.3 255.255.255.0
interface LoopBack0
ip address 10.0.3.3 255.255.255.0
interface LoopBack1
ip address 172.16.0.1 255.255.255.0
测试:
[R1]ping -c 2 10.0.12.2
PING 10.0.12.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=50 ms
Reply from 10.0.12.2: bytes=56 Sequence=2 ttl=255 time=10 ms
[R1]ping -c 2 10.0.13.3
PING 10.0.13.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.13.3: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 10.0.13.3: bytes=56 Sequence=2 ttl=255 time=10 ms
二、OSPF配置如下:
[R1]ospf 1 router-id 10.0.1.1 ====启用OPSF进程,默认进程ID为1.进程ID只具有本地意义,所以同一区域的不同路由器可以使用相同或者不同进程ID。
[R1-ospf-1]are 0
[R1-ospf-1-area-0.0.0.0]network 10.0.1.0 0.0.0.255 =====network后面配置反掩码
[R1-ospf-1-area-0.0.0.0]network 10.0.13.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255
[R2]ospf 10 router-id 10.0.2.2
[R2-ospf-10]area 0
[R2-ospf-10-area-0.0.0.0]network 10.0.12.0 0.0.0.255
[R2-ospf-10-area-0.0.0.0]network 10.0.2.0 0.0.0.255
[R3]ospf 100 router-id 10.0.3.3
[R3-ospf-100]area 0
[R3-ospf-100-area-0.0.0.0]network 10.0.13.0 0.0.0.255
[R3-ospf-100-area-0.0.0.0]network 10.0.3.0 0.0.0.255
R1>display ip routing-table protocol ospf ====查看路由表中OSPF路由信息
Route Flags: R – relay, D – download to fib
——————————————————————————
Public routing table : OSPF
Destinations : 2 Routes : 2
OSPF routing table status :
Destinations : 2 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0
10.0.3.3/32 OSPF 10 1 D 10.0.13.3 GigabitEthernet0/0/0
OSPF routing table status :
Destinations : 0 Routes : 0
测试:
PING 10.0.2.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.2.2: bytes=56 Sequence=1 ttl=255 time=10 ms
— 10.0.2.2 ping statistics —
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/10/10 ms
PING 10.0.3.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=255 time=10 ms
— 10.0.3.3 ping statistics —
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/10/10 ms
OSPF Process 1 with Router ID 10.0.12.1
Neighbors
Area 0.0.0.0 interface 10.0.12.1(Serial1/0/0)’s neighbors
Router ID: 10.0.2.2 Address: 10.0.12.2
State: Full Mode:Nbr is Slave Priority: 1
DR: None BDR: None MTU: 0
Dead timer due in 32 sec
Retrans timer interval: 5
Neighbor is up for 00:09:52
Authentication Sequence: [ 0 ]
Neighbors
Area 0.0.0.0 interface 10.0.13.1(GigabitEthernet0/0/0)’s neighbors
Router ID: 10.0.3.3 Address: 10.0.13.3
State: Full Mode:Nbr is Slave Priority: 1
DR: 10.0.13.1 BDR: 10.0.13.3 MTU: 0
Dead timer due in 34 sec
Retrans timer interval: 5
Neighbor is up for 00:06:50
Authentication Sequence: [ 0 ]
OSPF Process 1 with Router ID 10.0.12.1
Peer Statistic Information
—————————————————————————-
Area Id Interface Neighbor id State
0.0.0.0 Serial1/0/0 10.0.2.2 Full
0.0.0.0 GigabitEthernet0/0/0 10.0.3.3 Full
三、修改OSPF Hello和Dead时间
OSPF Process 1 with Router ID 10.0.12.1
Interfaces
Interface: 10.0.13.1 (GigabitEthernet0/0/0)
Cost: 1 State: DR Type: Broadcast MTU: 1500
Priority: 1
Designated Router: 10.0.13.1
Backup Designated Router: 10.0.13.3
Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ospf timer hello 15
[R3-GigabitEthernet0/0/0]ospf timer dead 60
Route Flags: R – relay, D – download to fib
——————————————————————————
Public routing table : OSPF
Destinations : 1 Routes : 1
OSPF routing table status :
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0
OSPF routing table status :
Destinations : 0 Routes : 0
注:由于R1和R3之间hello与dead时间不一致,所以邻居无法建立。
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ospf timer hello 15
[R1-GigabitEthernet0/0/0]ospf timer dead 60
[R1]display ip routing-table protocol ospf
Route Flags: R – relay, D – download to fib
——————————————————————————
Public routing table : OSPF
Destinations : 2 Routes : 2
OSPF routing table status :
Destinations : 2 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0
10.0.3.3/32 OSPF 10 1 D 10.0.13.3 GigabitEthernet0/0/0
OSPF routing table status :
Destinations : 0 Routes : 0
=================OSPF邻居建立必要条件================
1.router-id不能相同
2.hello and dead 必须相同
3.区域ID必须相同
4.认证key-id及密码必须相同
5.特殊区域标记相同
6.三层MTU必须相同
7.子网掩码必须相同(在一个需要DR|BDR环境中)
8.最小范围内的双向互通
==============================================
四、OSPF重分布默认路由
[R3]ip route-static 0.0.0.0 0 lo 1
[R3]ospf 100
[R3-ospf-100]default-route-advertise ====重分布默认路由
Route Flags: R – relay, D – download to fib
——————————————————————————
Public routing table : OSPF
Destinations : 3 Routes : 3
OSPF routing table status :
Destinations : 3 Routes : 3
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 O_ASE 150 1 D 10.0.13.3 GigabitEthernet0/0/0
OSPF routing table status :
Destinations : 0 Routes : 0
PING 172.16.0.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.0.1: bytes=56 Sequence=1 ttl=255 time=10 ms
Reply from 172.16.0.1: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 172.16.0.1: bytes=56 Sequence=3 ttl=255 time=10 ms
五、OSPF DR/BDR选举
OSPF Process 1 with Router ID 10.0.12.1
Neighbors
Area 0.0.0.0 interface 10.0.12.1(Serial1/0/0)’s neighbors
Router ID: 10.0.2.2 Address: 10.0.12.2
State: Full Mode:Nbr is Slave Priority: 1
DR: None BDR: None MTU: 0
Dead timer due in 31 sec
Retrans timer interval: 5
Neighbor is up for 01:17:49
Authentication Sequence: [ 0 ]
Neighbors
Area 0.0.0.0 interface 10.0.13.1(GigabitEthernet0/0/0)’s neighbors
Router ID: 10.0.3.3 Address: 10.0.13.3
State: Full Mode:Nbr is Slave Priority: 1
DR: 10.0.13.1 BDR: 10.0.13.3 MTU: 0
Dead timer due in 59 sec
Retrans timer interval: 5
Neighbor is up for 00:30:15
Authentication Sequence: [ 0 ]
注:默认优先级是1,由于R3 router-id大于R1 router-id所以R3为DR,R1为BDR。
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ospf dr-priority 200 ====配置OSPF优先级为200
注:由于DR/BDR选举默认为不抢占模式,因此修改了优先级后,不会重新进行选举,所以要重置R1与R3之间邻居关系。
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]shut
[R1-GigabitEthernet0/0/0]undo shut
OSPF Process 100 with Router ID 10.0.3.3
Neighbors
Area 0.0.0.0 interface 10.0.13.3(GigabitEthernet0/0/0)’s neighbors
Router ID: 10.0.12.1 Address: 10.0.13.1
State: Full Mode:Nbr is Master Priority: 200
DR: 10.0.13.1 BDR: 10.0.13.3 MTU: 0
Dead timer due in 52 sec
Retrans timer interval: 5
Neighbor is up for 00:02:10
Authentication Sequence: [ 0 ]
拓扑二
六、配置OSPF多区域
R1:
[R1]ospf 1 router-id 10.0.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]quit
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]network 10.0.13.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]network 10.0.1.0 0.0.0.255
R2:
[R2]ospf 1 router-id 10.0.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 10.0.2.0 0.0.0.255
R3:
[R3]ospf 1 router-id 10.0.3.3
[R3-ospf-1]area 1
[R3-ospf-1-area-0.0.0.1]network 10.0.3.0 0.0.0.255
[R3-ospf-1-area-0.0.0.1]network 10.0.13.0 0.0.0.255
测试:
Route Flags: R – relay, D – download to fib
——————————————————————————
Public routing table : OSPF
Destinations : 2 Routes : 2
OSPF routing table status :
Destinations : 2 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0
10.0.3.3/32 OSPF 10 1 D 10.0.13.3 GigabitEthernet0/0/0
OSPF routing table status :
Destinations : 0 Routes : 0
Route Flags: R – relay, D – download to fib
——————————————————————————
Public routing table : OSPF
Destinations : 3 Routes : 3
OSPF routing table status :
Destinations : 3 Routes : 3
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.1.1/32 OSPF 10 48 D 10.0.12.1 Serial1/0/0
10.0.3.3/32 OSPF 10 49 D 10.0.12.1 Serial1/0/0
10.0.13.0/24 OSPF 10 49 D 10.0.12.1 Serial1/0/0
OSPF routing table status :
Destinations : 0 Routes : 0
PING 10.0.3.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 10.0.3.3: bytes=56 Sequence=2 ttl=255 time=20 ms
PING 10.0.2.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.2.2: bytes=56 Sequence=1 ttl=255 time=10 ms
Reply from 10.0.2.2: bytes=56 Sequence=2 ttl=255 time=10 ms
OSPF Process 1 with Router ID 10.0.1.1
Peer Statistic Information
—————————————————————————-
Area Id Interface Neighbor id State
0.0.0.0 Serial1/0/0 10.0.2.2 Full
0.0.0.1 GigabitEthernet0/0/0 10.0.3.3 Full
七、OSPF直连路由重分布
[R3]ospf 1
[R3-ospf-1]import-route direct ====重分布直连
测试:
Route Flags: R – relay, D – download to fib
——————————————————————————
Public routing table : OSPF
Destinations : 4 Routes : 4
OSPF routing table status :
Destinations : 4 Routes : 4
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0
10.0.3.0/24 O_ASE 150 1 D 10.0.13.3 GigabitEthernet0/0/0
10.0.3.3/32 OSPF 10 1 D 10.0.13.3 GigabitEthernet0/0/0
172.16.0.0/24 O_ASE 150 1 D 10.0.13.3 GigabitEthernet0/0/0
注:O_ASE表示OSPF外部路由
PING 10.0.3.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=254 time=20 ms
Reply from 10.0.3.3: bytes=56 Sequence=2 ttl=254 time=10 ms
Reply from 10.0.3.3: bytes=56 Sequence=3 ttl=254 time=20 ms
Reply from 10.0.3.3: bytes=56 Sequence=4 ttl=254 time=20 ms
R1>display ospf lsdb ==== 查看LSA数据库
OSPF Process 1 with Router ID 10.0.1.1
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.0.2.2 10.0.2.2 1536 60 80000003 48
Router 10.0.1.1 10.0.1.1 1558 48 80000003 48
Sum-Net 10.0.13.0 10.0.1.1 1773 28 80000001 1
Sum-Net 10.0.3.3 10.0.1.1 1407 28 80000001 1
Sum-Net 10.0.1.1 10.0.1.1 1766 28 80000001 0
Sum-Asbr 10.0.3.3 10.0.1.1 522 28 80000001 1
Area: 0.0.0.1
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.0.3.3 10.0.3.3 523 48 80000005 1
Router 10.0.1.1 10.0.1.1 1399 48 80000006 1
Network 10.0.13.1 10.0.1.1 1399 32 80000002 0
Sum-Net 10.0.12.0 10.0.1.1 1773 28 80000001 48
Sum-Net 10.0.2.2 10.0.1.1 1535 28 80000001 48
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 10.0.3.0 10.0.3.3 523 36 80000001 1
External 10.0.13.0 10.0.3.3 523 36 80000001 1
External 172.16.0.0 10.0.3.3 523 36 80000001 1
OSPF Process 1 with Router ID 10.0.1.1
Area: 0.0.0.0
Link State Database
Type : Sum-Net
Ls id : 10.0.3.3
Adv rtr : 10.0.1.1
Ls age : 1693
Len : 28
Options : E
seq# : 80000001
chksum : 0x4cf3
Net mask : 255.255.255.255
Tos 0 metric: 1
Priority : Low
Area: 0.0.0.1
Link State Database
OSPF Process 1 with Router ID 10.0.1.1
Area: 0.0.0.0
Link State Database
Type : Sum-Asbr
Ls id : 10.0.3.3
Adv rtr : 10.0.1.1
Ls age : 1031
Len : 28
Options : E
seq# : 80000001
chksum : 0x3e01
Tos 0 metric: 1
Area: 0.0.0.1
Link State Database
OSPF Process 1 with Router ID 10.0.1.1
Link State Database
Type : External
Ls id : 172.16.0.0
Adv rtr : 10.0.3.3
Ls age : 1109
Len : 36
Options : E
seq# : 80000001
chksum : 0xf70c
Net mask : 255.255.255.0
TOS 0 Metric: 1
E type : 2
Forwarding Address : 0.0.0.0
Tag : 1
Priority : Low
八、配置OSPF认证
[R1]int s1/0/0
[R1-Serial1/0/0]ospf authentication-mode simple plain ccieh3c.com
[R2]int s1/0/0
[R2-Serial1/0/0]ospf authentication-mode simple plain ccieh3c.com
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher ccieh3c.com
[R2-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher ccieh3c.com
下载对应文档
关于博客资源下载说明
(1)第一种是书籍PDF与视频类,全部放在博客分享,觉得对大家学习有帮助的博主会收集好、然后以博主的经验整理分类后排序好分享出来。
(2)第二种是技术性文章与视频,全部放在公众号(网络之路博客)/B站(网络之路Blog)发布,以博主原创为主,主要分享系列为主,由浅入深的带大家了解工作中常用到的一些网络技术,当然也会分享一些比较经典的案例。
(3)分享资源有涉及到您的利益以及版权问题,请联系博主,24小时候内删除。
学习视频系列(总有您想要的)
Book与实验手册(从初级到高级)
数通系列(路由交换 无线、防火墙VPN等)
实战系列(最贴近企业需求的案例)
想第一时间收到最新更新内容吗,点击获取~~~