OSPF实验一

拓扑图

如图所示,使用ospf路由协议来实现全网互通

先为路由器的各个端口配置ip地址

router 1的配置

Router>en
Router#conf t
Router(config)#hostname Router1
Router1(config)#int l0
Router1(config-if)#
Router1(config-if)#ip addr 1.1.1.1 255.255.255.0
Router1(config-if)#no shu
Router1(config-if)#exit
Router1(config)#int s0/3/0
Router1(config-if)#ip addr 192.168.1.1 255.255.255.0
Router1(config-if)#no shu

router 2的配置

Router>en
Router#conf t
Router(config)#hostname Router2
Router2(config)#int l0
Router2(config-if)#ip addr 2.2.2.2 255.255.255.0
Router2(config-if)#no shu
Router2(config-if)#exit
Router2(config)#int s0/3/0
Router2(config-if)#ip addr 192.168.1.2 255.255.255.0
Router2(config-if)#no shu
Router2(config-if)#exit
Router2(config)#int s0/3/1
Router2(config-if)#ip addr 192.168.2.1 255.255.255.0
Router2(config-if)#no shu

router 3的配置

Router>en
Router#conf t
Router(config)#hostname Router3
Router3(config)#int l0
Router3(config-if)#ip addr 3.3.3.3 255.255.255.0
Router3(config-if)#no shu
Router3(config-if)#exit
Router3(config)#int s0/3/1
Router3(config-if)#ip addr 192.168.2.2 255.255.255.0
Router3(config-if)#no shu
Router3(config-if)#exit
Router3(config)#int s0/3/0
Router3(config-if)#ip addr 192.168.3.1 255.255.255.0
Router3(config-if)#no shu

router 4的配置

Router>en
Router#conf t
Router(config)#hostname Router4
Router4(config)#int l0
Router4(config-if)#ip addr 4.4.4.4 255.255.255.0
Router4(config-if)#exit
Router4(config)#int s0/3/0
Router4(config-if)#ip addr 192.168.3.2 255.255.255.0
Router4(config-if)#no shu

配置ospf路由协议

router 1的配置

Router1(config)#router ospf 1
Router1(config-router)#routet-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
Router1(config-router)#exit

router 2的配置

Router2(config)#router ospf 1
Router2(config-router)#router-id 2.2.2.2
Router2(config-router)#network 2.2.2.0 0.0.0.255 area 0
Router2(config-router)#network 192.168.1.0 0.0.0.255 area 0
Router2(config-router)#network 192.168.2.0 0.0.0.255 area 0
Router2(config-router)#exit

router 3的配置

Router3(config-if)#exit
Router3(config)#router ospf 1
Router3(config-router)#router-id 3.3.3.3
Router3(config-router)#network 3.3.3.0 0.0.0.255 area 0
Router3(config-router)#network 192.168.2.0 0.0.0.255 area 0
Router3(config-router)#network 192.168.3.0 0.0.0.255 area 0
Router3(config-router)#exit

router 4的配置

Router4(config)#router ospf 1
Router4(config-router)#router-id 4.4.4.4
Router4(config-router)#network 4.4.4.0 0.0.0.255 area 0
Router4(config-router)#network 192.168.3.0 0.0.0.255 area 0
Router4(config-router)#exit

ospf 配置完成查看router 1路由表

Router1#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route
Gateway of last resort is not set
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.168.1.2, 00:03:26, Serial0/3/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/129] via 192.168.1.2, 00:01:34, Serial0/3/0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/193] via 192.168.1.2, 00:00:09, Serial0/3/0
C    192.168.1.0/24 is directly connected, Serial0/3/0
O    192.168.2.0/24 [110/128] via 192.168.1.2, 00:03:26, Serial0/3/0
O    192.168.3.0/24 [110/192] via 192.168.1.2, 00:01:34, Serial0/3/0
 
查看ospf数据库的信息
 
Router1#show ip ospf database
            OSPF Router with ID (1.1.1.1) (Process ID 1)
                Router Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         296         0x80000005 0x005275 3
2.2.2.2         2.2.2.2         189         0x80000005 0x0087b4 5
3.3.3.3         3.3.3.3         110         0x80000005 0x00071d 5
4.4.4.4         4.4.4.4         110         0x80000003 0x009408 3
 
用ping命令检查网络是否互通
 
router 1 ping  router 2
 
Router1#ping 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/8/12 ms
 
router 1 ping router 3
 
Router1#ping 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 11/11/13 ms
 
router 1 ping router 4
 

Router1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 10/14/18 ms
 
已实现全网互通,实验完成
posted @ 2018-06-26 14:21  knightysa  阅读(221)  评论(0编辑  收藏  举报