动态路由之OSPF协议的配置

对于OSPF是由IETF开发的路由选择协议,属于内部网关协议(IGP),不同于RIP的距离矢量协议,OSPF是链路状态协议,和距离矢量相比具有收敛速度快、更适合于大型网络。
目前OSPF是运用比较广泛的路由动态协议,他不是CISCO专有的路由协议,可以互联CISCO、华为等多个公司的路由器,兼容性非常不错。
OSPF协议可以运行在三种拓扑结构中:广播型多路访问(Broadcast Multi-Access)、点到点拓扑结构(Point To Point)、非广播型多路访问(Non-Broadcast Multi-Access,NBMA):
今天做的是点到点拓扑结构(在此网络中无DR/BDR-关于这两个就不在细说)。
有问题大家在讨论,接下来我们先来看如下拓扑图:
Router1配置:
Press Enter to Start

Router>enable
Router#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname Route1
Route1(config)#interface e0
Route1(config-if)#ip address 192.168.1.2 255.255.255.0
Route1(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Ethernet0, changed state to up
Route1(config-if)#interface s0
Route1(config-if)#ip address 192.168.2.1 255.255.255.0
Route1(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Serial0, changed state to up
%LINK-3-UPDOWN: Interface Serial0, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down
Route1(config-if)#en
Route1(config-if)#encapsulation ppp
Route1(config-if)#clock rate 64000
Route1(config-if)#exit
Route1(config)#route ?
rip                     Routing Information Protocol (RIP)
igrp                    Interior Gateway Routing Protocol (IGRP)
eigrp                   Enhanced Interior Gateway Routing Protocol (EIGRP)
ospf                    Open Shortest Path First (OSPF)
bgp                     Border Gateway Protocol (BGP)
isis                    ISO IS-IS
word                    Route map tag
Route1(config)#route ospf ?
<1-65535>               Process ID
Route1(config)#route ospf 1    //启用ospf协议
Route1(config-router)#network 192.168.2.0 0.0.0.255 area 0    //发布邻接网络
Route1(config-router)#network 192.168.1.0 0.0.0.255 area 0    //此处分别为192.168.1.0和192.168.2.0
Route1(config-router)#exit
Route1(config)#exit
Route1#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]

Router2配置:
Press Enter to Start

Router>enable
Router#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname Route2
Router2(config)#interface e0
Router2(config-if)#ip address 192.168.3.1 255.255.255.0
Router2(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Ethernet0, changed state to up
Router2(config-if)#interface s1
Router2(config-if)#ip address 192.168.2.2 255.255.255.0
Router2(config-if)#encapsulation ppp
Router2(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Serial1, changed state to up
Router2(config-if)#exit
Router2(config)#exit
Router2#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router2(config)#route ospf 1    //启用ospf协议
Router2(config-router)#network 192.168.2.0 0.0.0.255 area 0    //发布邻接网络
Router2(config-router)#network 192.168.3.0 0.0.0.255 area 0    //此处分别为192.168.3.0和192.168.2.0
Router2(config-router)#exit
Router2(config)#exit
Router2#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]

PC1的配置:
Boson BOSS 5.0
Copyright 1998-2003 Boson Software, Inc.
Use the command help to get started
Press Enter to begin
C:>
C:>winip?
winipcfg           
C:>winipcfg中进行配置IP:192.168.1.1 255.255.255.0 网关:192.168.1.2

PC2的配置:
Boson BOSS 5.0
Copyright 1998-2003 Boson Software, Inc.
Use the command help to get started
Press Enter to begin
C:>
C:>winip?
winipcfg           
C:>winipcfg中进行配置IP:192.168.3.2 255.255.255.0 网关:192.168.3.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
       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, * - candidate default
       U - per-user static route
Gateway of last resort is not set
     192.168.1.0/24 is subnetted, 1 subnets
C       192.168.1.0 is directly connected, Ethernet0
     192.168.2.0/24 is subnetted, 1 subnets
C       192.168.2.0 is directly connected, Serial0
     192.168.3.0/24 is subnetted, 1 subnets
O       192.168.3.0 [110/64] via 192.168.3.1, 00:14:53, Serial0    //ospf学来的路由条目

Router2#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
       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, * - candidate default
       U - per-user static route
Gateway of last resort is not set
     192.168.3.0/24 is subnetted, 1 subnets
C       192.168.3.0 is directly connected, Ethernet0
     192.168.2.0/24 is subnetted, 1 subnets
C       192.168.2.0 is directly connected, Serial1
     192.168.1.0/24 is subnetted, 1 subnets
O       192.168.1.0 [110/64] via 192.168.2.1, 00:15:33, Serial1     //ospf学来的路由条目

P1PingP2:
C:>ping 192.168.3.2
Pinging 192.168.3.2 with 32 bytes of data:
Reply from 192.168.3.2: bytes=32 time=60ms TTL=241
Reply from 192.168.3.2: bytes=32 time=60ms TTL=241
Reply from 192.168.3.2: bytes=32 time=60ms TTL=241
Reply from 192.168.3.2: bytes=32 time=60ms TTL=241
Reply from 192.168.3.2: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.3.2:     Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
     Minimum = 50ms, Maximum = 60ms, Average = 55ms

成功!!

你可能感兴趣的:(职场,协议,路由,休闲,ospf)