1.OSPF概念
OSPF(Open Shortest Path First,开放最短路径优先)是一种基于链路状态的内部网关协议(IGP),主要用于自治系统(AS)内部的路由决策。它通过维护网络拓扑结构的链路状态数据库,使用 Dijkstra(迪杰斯特拉)算法计算出到达各目标网络的最短路径,实现高效的路由选择。
2.模拟拓扑实现
3.配置ip地址
根据拓扑图,对交换机1~3进行vlan与端口配置。 交换机1:
sys
hostname switch1
vlan 10
interface Vlan-interface 10
ip address 192.168.1.1 255.255.255.0
quit
批量设置端口
interface range g1/0/1 to g1/0/9
port link-type access
port access vlan 10
vlan 20
interface Vlan-interface 20
ip address 192.168.10.1 255.255.255.0
quit
interface range g1/0/10 to g1/0/19
port link-type access
port access vlan 20
save
交换机2:
sys
hostname switch2
vlan 30
interface Vlan-interface 30
ip address 192.168.10.2 255.255.255.0
quit
批量设置端口
interface range g1/0/1 to g1/0/9
port link-type access
port access vlan 30
vlan 40
interface Vlan-interface 40
ip address 10.10.10.1 255.255.255.0
quit
interface range g1/0/10 to g1/0/19
port link-type access
port access vlan 40
save
交换机3:
sys
hostname switch3
vlan 50
interface Vlan-interface 50
ip address 10.10.10.2 255.255.255.0
quit
批量设置端口
interface range g1/0/1 to g1/0/9
port link-type access
port access vlan 50
vlan 60
interface Vlan-interface 60
ip address 10.1.1.1 255.255.255.0
quit
interface range g1/0/10 to g1/0/19
port link-type access
port access vlan 60
save
同时将PC1和PC2的地址按拓扑配置完成
4.配置OSPF
显然PC1是ping不通PC2的。
配置三个交换机OSPF,交换机1:
ospf 100 router-id 192.168.1.1
创建区域0并进和区域
area 0
公示本机路由
network 192.168.1.0 0.0.0.255
network 192.168.10.0 0.0.0.255
返回ospf进程
quit
静默此vlan 不广播到ospf。此vlan下为终端设备,不需要ospf报文增加设备压力
silent-interface Vlan-interface 10
quit
save
交换机2:
ospf 100 router-id 10.10.10.1
创建区域0并进和区域
area 0
公示本机路由
network 192.168.10.0 0.0.0.255
network 10.10.10.0 0.0.0.255
quit
save
交换机3:
ospf 100 router-id 10.1.1.1
创建区域0并进和区域
area 0
公示本机路由
network 10.10.10.0 0.0.0.255
network 10.1.1.0 0.0.0.255
返回ospf进程
quit
静默此vlan 不广播到ospf。此vlan下为终端设备,不需要ospf报文增加设备压力
silent-interface Vlan-interface 60
quit
save
5.测试与查看
此时PC1已经可以正常Ping通PC2了image
查看交换机的路由表,发现已经可以正常学习到路由表了,至此实验结束。
dis ospf routing
声明:来自运维贼船,仅代表创作者观点。链接:https://eyangzhen.com/3289.html