HCIA路由实验-OSPF和静态路由配置
Posted 朔方鸟
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HCIA路由实验-OSPF和静态路由配置相关的知识,希望对你有一定的参考价值。
一、OSPF实验
OSPF是指开放式最短路径优先协议,其具有灵活性好、易于扩展的特性,同时,其具有较高的可靠性。
OSPF的更新为触发更新,其建立路由表的过程如下:
① 建立邻居关系(确认其他路由器是否开启OSPF)
② 泛洪LSA(发送LSA)
③ 收集全网LSA得到LSDB(链路状态数据库)
④ 以自身为根计算最优路径
以下是OSPF动态路由实验的基本步骤:
实验拓扑如下:
步骤一:如图配置路由器的IP地址
对R1:
[R1]int lo 0
[R1-LoopBack0]ip address 1.1.1.1 32
[R1-LoopBack0]int g0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.1 24
对R2:
[R2]int lo0
[R2-LoopBack0]ip address 2.2.2.2 32
[R2-LoopBack0]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.1.2 24
对R3:
[R3]int lo0
[R3-LoopBack0]ip address 3.3.3.3 32
[R3-LoopBack0]int g0/0/0
[R3-GigabitEthernet0/0/0]ip address 192.168.1.3 24
对R4:
[R4]int lo0
[R4-LoopBack0]ip address 4.4.4.4 32
[R4-LoopBack0]int g0/0/0
[R4-GigabitEthernet0/0/0]ip address 192.168.1.4 24
步骤二:进行OSPF配置
对R1:
[R1]ospf 1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
对R2:
[R2]ospf
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
对R3:
[R3]ospf
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
对R4:
[R4]ospf
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
验证:
① 查看OSPF邻居关系是否建立
对R1:
[R1]dis ospf peer brief
OSPF Process 1 with Router ID 1.1.1.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 2-Way
0.0.0.0 GigabitEthernet0/0/0 3.3.3.3 Full
0.0.0.0 GigabitEthernet0/0/0 4.4.4.4 Full
----------------------------------------------------------------------------
② 查看路由器之间能否相互ping通(这里以R1为例)
对R1:
[R1]ping 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=60 ms
Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=40 ms
Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=60 ms
Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=40 ms
--- 2.2.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/50/60 ms
[R1]ping 3.3.3.3
PING 3.3.3.3: 56 data bytes, press CTRL_C to break
Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=255 time=70 ms
Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=255 time=40 ms
Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=255 time=50 ms
Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=255 time=40 ms
Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=255 time=40 ms
--- 3.3.3.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/48/70 ms
[R1]ping 4.4.4.4
PING 4.4.4.4: 56 data bytes, press CTRL_C to break
Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=255 time=60 ms
Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=255 time=50 ms
Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=255 time=60 ms
Reply from 4.4.4.4: bytes=56 Sequence=5 ttl=255 time=60 ms
--- 4.4.4.4 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/56/60 ms
路由器之间可以ping通,实验完成。
OSPF实验扩展:
① 修改R3 Router-id 为 3.3.3.3
对R3:
[R3]router id 3.3.3.3
② 修改R3 的 dr 优先级为100
[R3]int g 0/0/0
[R3-GigabitEthernet0/0/0]ospf dr-priority 100
③ 修改R3的OSPF的cost值为1000
[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]ospf cost 1000
④ 修改R3的参考带宽为1000
[R3]ospf
[R3-ospf-1]bandwidth-reference 1000
二、静态路由
静态路由指由网络管理员手动配置的路由条目,适用于对系统要求低的简单小型网络,与动态路由相比,其不能自适应网络变化,需人为干预。
以下是配置静态路由的基本步骤:
实验拓扑如下:
实验说明:实验效果为每台设备可到达其它设备的loopback接口的IP
实验步骤:
步骤一: 如图配置路由器的IP地址
对R1:
[R1]int lo 0
[R1-LoopBack0]ip address 1.1.1.1 32
[R1-LoopBack0]int g0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.1 24
对R2:
[R2]int lo0
[R2-LoopBack0]ip address 2.2.2.2 32
[R2-LoopBack0]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.1.2 24
对R3:
[R3]int lo0
[R3-LoopBack0]ip address 3.3.3.3 32
[R3-LoopBack0]int g0/0/0
[R3-GigabitEthernet0/0/0]ip address 192.168.1.3 24
对R4:
[R4]int lo0
[R4-LoopBack0]ip address 4.4.4.4 32
[R4-LoopBack0]int g0/0/0
[R4-GigabitEthernet0/0/0]ip address 192.168.1.4 24
步骤二:进行静态路由配置
对R1:
[R1]ip route-static 2.2.2.2 32 192.168.1.2
[R1]ip route-static 3.3.3.3 32 192.168.1.3
[R1]ip route-static 4.4.4.4 32 192.168.1.4
对R2:
[R2]ip route-static 1.1.1.1 32 192.168.1.1
[R2]ip route-static 3.3.3.3 32 192.168.1.3
[R2]ip route-static 4.4.4.4 32 192.168.1.4
对R3:
[R3]ip route-static 1.1.1.1 32 192.168.1.1
[R3]ip route-static 2.2.2.2 32 192.168.1.2
[R3]ip route-static 4.4.4.4 32 192.168.1.4
对R4:
[R4]ip route-static 1.1.1.1 32 192.168.1.1
[R4]ip route-static 2.2.2.2 32 192.168.1.2
[R4]ip route-static 3.3.3.3 32 192.168.1.3
验证:路由器的loopback接口可互相通信(这里以R1为例)
对R1:
[R1]ping 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=40 ms
Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=60 ms
Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=50 ms
Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=40 ms
--- 2.2.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/48/60 ms
[R1]ping 3.3.3.3
PING 3.3.3.3: 56 data bytes, press CTRL_C to break
Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=255 time=110 ms
Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=255 time=70 ms
Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=255 time=50 ms
Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=255 time=40 ms
--- 3.3.3.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/60/110 ms
[R1]ping 4.4.4.4
PING 4.4.4.4: 56 data bytes, press CTRL_C to break
Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=255 time=90 ms
Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=255 time=40 ms
Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=255 time=60 ms
Reply from 4.4.4.4: bytes=56 Sequence=5 ttl=255 time=60 ms
--- 4.4.4.4 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/60/90 ms
以上是关于HCIA路由实验-OSPF和静态路由配置的主要内容,如果未能解决你的问题,请参考以下文章
多种动态路由混合架构实验——OSPF协议+RIP协议+静态路由