OSPF实验二

拓扑图

如图所示,使用ospf协议达全网互通

为计算机和路由器配置IP地址

router 1 的配置

Router>en
Router#conf t
Router(config)#hostname Router1
Router1(config)#int f0/0
Router1(config-if)#ip addr 192.168.1.2 255.255.255.0
Router1(config-if)#no shu
Router1(config-if)#exit
Router1(config)#int f0/1
Router1(config-if)#ip addr 192.168.10.1 255.255.255.0
Router1(config-if)#no shu
Router1(config-if)#exit

router 2的配置

Router>en
Router#conf t
Router(config)#hostname Router2
Router2(config)#int f0/0
Router2(config-if)#ip addr 192.168.2.2 255.255.255.0
Router2(config-if)#no shu
Router2(config-if)#exit
Router2(config)#int f0/1
Router2(config-if)#ip addr 192.168.20.1 255.255.255.0
Router2(config-if)#no shu
Router2(config-if)#exit

router 3的配置

Router>en
Router#conf t
Router(config)#hostname Router3
Router3(config)#int f0/0
Router3(config-if)#ip addr 192.168.3.2 255.255.255.0
Router3(config-if)#no shu
Router3(config-if)#int f0/1
Router3(config-if)#ip addr 192.168.30.1 255.255.255.0
Router3(config-if)#no shu

router 4的配置

Router>en
Router#conf t
Router(config)#hostname Router4
Router4(config)#int f0/1
Router4(config-if)#ip addr 192.168.10.2 255.255.255.0
Router4(config-if)#no shu
Router4(config-if)#exit
Router4(config)#int s0/3/0
Router4(config-if)#ip addr 10.1.1.1 255.255.255.0
Router4(config-if)#no shu
Router4(config-if)#exit
Router4(config)#int s0/3/1
Router4(config-if)#ip addr 30.1.1.1 255.255.255.0
Router4(config-if)#no shu
Router4(config-if)#exit

router 5的配置

Router>en
Router#conf t
Router(config)#hostname Router5
Router5(config)#int f0/1
Router5(config-if)#ip addr 192.168.20.2 255.255.255.0
Router5(config-if)#no shu
Router5(config-if)#exit
Router5(config)#int s0/3/0
Router5(config-if)#ip addr 10.1.1.2 255.255.255.0
Router5(config-if)#no shu
Router5(config-if)#exit
Router5(config)#int s0/3/1
Router5(config-if)#ip addr 20.1.1.1 255.255.255.0
Router5(config-if)#no shu

router 6的配置

Router>en
Router#conf t
Router(config)#int f0/1
Router(config-if)#ip addr 192.168.30.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#exit
Router(config)#int s0/3/0
Router(config-if)#ip addr 30.1.1.1 255.255.255.0
Router(config-if)#no shu
Router(config-if)#exit
Router(config)#int s0/3/1
Router(config-if)#ip addr 20.1.1.2 255.255.255.0
Router(config-if)#no shu

IP配置完成后配置ospf路由协议

router 1的配置

Router1(config)#router ospf 1
Router1(config-router)#router-id 1.1.1.1
Router1(config-router)#network 192.168.1.0 0.0.0.255 area 0
Router1(config-router)#network 192.168.10.0 0.0.0.255 area 0
Router1(config-router)#end

router 2的配置

Router2(config)#router ospf 1
Router2(config-router)#router-id 2.2.2.2
Router2(config-router)#network 192.168.2.0 0.0.0.255 area 0
Router2(config-router)#network 192.168.20.0 0.0.0.255 area 0
Router2(config-router)#end

router 3的配置

Router3(config)#router ospf 1
Router3(config-router)#router 3.3.3.3
Router3(config-router)#network 192.168.3.0 0.0.0.255 area 0
Router3(config-router)#network 192.168.30.0 0.0.0.255 area 0
Router3(config-router)#end

router 4的配置

Router4(config)#router ospf  1
Router4(config-router)#router-id 4.4.4.4
Router4(config-router)#network 192.168.10.0 0.0.0.255 area 0
Router4(config-router)#network 10.1.1.0 0.0.0.255 area 0
Router4(config-router)#network 30.1.1.0 0.0.0.255 area 0
Router4(config-router)#end

router 5的配置

Router5(config)#router ospf 1
Router5(config-router)#router-id 5.5.5.5
Router5(config-router)#network 192.168.20.0 0.0.0.255 area 0
Router5(config-router)#network 10.1.1.0 0.0.0.255 area 0
Router5(config-router)#network 20.1.1.0 0.0.0.255 area 0
Router5(config-router)#end

router 6的配置

Router(config)#router ospf 1
Router(config-router)#router-id 6.6.6.6
Router(config-router)#network 192.168.30.0 0.0.0.255 area 0
Router(config-router)#network 30.1.1.0 0.0.0.255 area 0
Router(config-router)#network 20.1.1.0 0.0.0.255 area 0
Router(config-router)#end

配置完成,查看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
     10.0.0.0/24 is subnetted, 1 subnets
O       10.1.1.0 [110/65] via 192.168.10.2, 00:24:40, FastEthernet0/1
     20.0.0.0/24 is subnetted, 1 subnets
O       20.1.1.0 [110/129] via 192.168.10.2, 00:21:23, FastEthernet0/1
     30.0.0.0/24 is subnetted, 1 subnets
O       30.1.1.0 [110/65] via 192.168.10.2, 00:24:17, FastEthernet0/1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
O    192.168.2.0/24 [110/67] via 192.168.10.2, 00:21:23, FastEthernet0/1
O    192.168.3.0/24 [110/67] via 192.168.10.2, 00:18:44, FastEthernet0/1
C    192.168.10.0/24 is directly connected, FastEthernet0/1
O    192.168.20.0/24 [110/66] via 192.168.10.2, 00:21:23, FastEthernet0/1
O    192.168.30.0/24 [110/66] via 192.168.10.2, 00:18:44, FastEthernet0/1
 
查看ip路由协议配置与统计信息
 
Router1#show ip  protocols
Routing Protocol is "ospf 1"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Router ID 1.1.1.1
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    192.168.1.0 0.0.0.255 area 0
    192.168.10.0 0.0.0.255 area 0
  Routing Information Sources: 
    Gateway         Distance      Last Update
    1.1.1.1              110      00:25:52
    2.2.2.2              110      00:23:20
    3.3.3.3              110      00:20:01
    4.4.4.4              110      00:19:59
    5.5.5.5              110      00:19:57
    6.6.6.6              110      00:19:57
  Distance: (default is 110)
 
查看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         1654        0x80000003 0x004b9b 2
2.2.2.2         2.2.2.2         1502        0x80000003 0x00d5f3 2
3.3.3.3         3.3.3.3         1303        0x80000003 0x00604c 2
4.4.4.4         4.4.4.4         1301        0x80000006 0x00146e 5
5.5.5.5         5.5.5.5         1299        0x80000006 0x006c11 5
6.6.6.6         6.6.6.6         1299        0x80000006 0x009e9e 5
                Net Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum
192.168.10.1    1.1.1.1         1654        0x80000001 0x00238c
192.168.20.1    2.2.2.2         1502        0x80000001 0x00b3a6
192.168.30.1    3.3.3.3         1303        0x80000001 0x007211
Router1#
 
用ping命令检查网络是否互通
 
pc1 ping pc2
 

 

pc1 ping pc3

 

以实现全网互通,实验完成

posted @ 2018-06-26 15:20  knightysa  阅读(195)  评论(0编辑  收藏  举报