拓扑图如下
路由器0
Router>en
Router#conf t
Router(config)#hostname router1
router1(config)#interface g0/0
router1(config-if)#ip address 192.168.1.1 255.255.255.0
router1(config-if)#no shutdown
router1(config-if)#exit
router1(config)#interface l0
router1(config-if)#ip address 1.1.1.1 255.255.255.0
router1(config-if)#no shutdown
router1(config-if)#exit
router1(config)#router ospf 1
router1(config-router)#router-id 1.1.1.1
router1(config-router)#network 1.1.1.0 0.0.0.255 area 0
router1(config-router)#network 192.168.1.0 0.0.0.255 area 0
路由器1
Router>enable
Router#conf t
Router(config)#hostname router2
router2(config)#interface g0/0
router2(config-if)#ip address 192.168.1.2 255.255.255.0
router2(config-if)#no shutdown
router2(config-if)#exit
router2(config)#interface l0
router2(config-if)#ip address 2.2.2.2 255.255.255.0
router2(config-if)#no shutdown
router2(config-if)#exit
router2(config)#router ospf 1
router2(config-router)#router-id 2.2.2.2
router2(config-router)#network 192.168.1.0 0.0.0.255 area 0
router2(config-router)#network 2.2.2.0 0.0.0.255 area 0
路由器2
Router>enable
Router#conf t
Router(config)#hostname router3
router3(config)#interface g0/0
router3(config-if)#ip address 192.168.1.3 255.255.255.0
router3(config-if)#no shutdown
router3(config-if)#exit
router3(config)#interface l0
router3(config-if)#ip address 3.3.3.3 255.255.255.0
router3(config-if)#no shutdown
router3(config-if)#exit
router3(config)#router ospf 1
router3(config-router)#router-id 3.3.3.3
router3(config-router)#network 192.168.1.0 0.0.0.255 area 0
router3(config-router)#network 3.3.3.0 0.0.0.255 area 0
路由器3
Router>en
Router#conf t
Router(config)#hostname router4
router4(config)#interface g0/0
router4(config-if)#ip address 192.168.1.4 255.255.255.0
router4(config-if)#no shutdown
router4(config-if)#exit
router4(config)#interface l0
router4(config-if)#ip address 4.4.4.4 255.255.255.0
router4(config-if)#no shutdown
router4(config-if)#exit
router4(config)#router ospf 1
router4(config-router)#router-id 4.4.4.4
router4(config-router)#network 192.168.1.0 0.0.0.255 area 0
router4(config-router)#network 4.4.4.0 0.0.0.255 area 0
设置完成
原文地址:https://www.cnblogs.com/ruanjie/p/9230166.html