版权声明:如果对大家有帮助,大家可以自行转载的。https://blog.csdn.net/qq_37992321/article/details/84843171
1.技术原理
OSPF 开放式最短路径优先协议,是目前网路中应用最广泛的路由协议之一。属于内部网管路由协议,能够适应各种规模的网络环境,是典型的链路状态协议。OSPF路由协议通过向全网扩散本设备的链路状态信息,使网络中每台设备最终同步一个具有全网链路状态的数据库,然后路由器采用 SPF 算法,以自己为根,计算到达其他网络的最短路径,最终形成全网路由信息。
动态路由是指路由器自动地建立自己的路由表,并且能够根据实际情况的变化适时地进行调整。动态路由的运作机制依赖路由器的两个基本功能:对路由表的维护和路由器之间适时的路由信息交换
2.拓扑图
3.为路由器各个端口和环回口配置IP地址
Router2
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int loopback 0
Router(config-if)#
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router(config-if)#ip add 1.1.1.1 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config-if)#int s2/0
Router(config-if)#ip add 192.168.12.1 255.255.255.0
Router(config-if)#no shu
Router3
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int loopback 0
Router(config-if)#
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router(config-if)#ip add 2.2.2.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#int s2/0
Router(config-if)#ip add 192.168.12.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
%LINK-5-CHANGED: Interface Serial2/0, changed state to up
Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up
Router(config-if)#int s3/0
Router(config-if)#ip add 192.168.23.1 255.255.255.0
Router(config-if)#no shu
Router4
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int loopback 0
Router(config-if)#
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router(config-if)#ip add 3.3.3.3 255.255.255.0
Router(config-if)#no shu
Router(config-if)#int s3/0
Router(config-if)#ip add 192.168.23.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
%LINK-5-CHANGED: Interface Serial3/0, changed state to up
Router(config-if)#int s2/0
Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial3/0, changed state to up
Router(config-if)#ip add 192.168.34.1 255.255.255.0
Router(config-if)#no shu
Router5
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int loopback 0
Router(config-if)#
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router(config-if)#ip add 4.4.4.4 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config-if)#int s2/0
Router(config-if)#ip add 192.168.34.2 255.255.255.0
Router(config-if)#no shu
4.在每个路由器上配置OSPF协议
Router2
Router(config)#router ospf 1
Router(config-router)#router-id 1.1.1.1
Router(config-router)#network 1.1.1.0 255.255.255.0 area 0
Router(config-router)#net 192.168.12.0 255.255.255.0 area 0
Router3
Router(config)#router ospf 1
Router(config-router)#router-id 2.2.2.2
Router(config-router)#network 2.2.2.0 255.255.255.0 area 0
Router(config-router)#network 192.168.12.0 255.255.255.0 area 0
Router(config-router)#network 192.168.23.0 255.255.255.0 area 0
Router4
Router(config)#router ospf 1
Router(config-router)#router-id 3.3.3.3
Router(config-router)#network 3.3.3.0 255.255.255.0 area 0
Router(config-router)#network 192.168.23.0 255.255.255.0 area 0
Router(config-router)#network 192.168.34.0 255.255.255.0 area 0
Router5
Router(config)#router ospf 1
Router(config-router)#router-id 4.4.4.4
Router(config-router)#network 4.4.4.0 255.255.255.0 area 0
Router(config-router)#network 192.168.34.0 255.255.255.0 area 0
5.网络测试
(1)查看路由器的路由表
show ip route
(2)Router2 ping Router 5
(3)Router2 ping Router5的环回口地址