现在的位置: 首页 > 综合 > 正文

ospf协议配置案例

2012年08月22日 综合 ⁄ 共 2971字 ⁄ 字号 暂无评论

route 1:0/0 192.168.1.1 route 2:0/0 192.168.3.1 route:0/1 192.168.4.1
route 1:0/1 192.168.2.1 route 2:0/1 192.168.2.2 route:0/0 192.168.3.1

PC1: ip 192.168.1.10 默认网关 192.168.1.1 (网关必须与连接第一个路由器的端口一致)
PC2: ip 192.168.4.10 默认网关 192.168.4.1
==========================================================================
Router>enable
Router#conf t
Router(config)#hostname r1
=========================================================
2.配置端口ip地址
r1(config)#int f0/0
r1(config-if)#ip address 192.168.1.1 255.255.255.0
r1(config-if)#no shutdown

r1(config-if)#int f0/1
r1(config-if)#ip address 192.168.2.1 255.255.255.0
r1(config-if)#no shutdown

r2(config-if)#int f0/0
r2(config-if)#ip address 192.168.3.1 255.255.255.0
r2(config-if)#no shutdown

r2(config)#int f0/1
r2(config-if)#ip address 192.168.2.2 255.255.255.0
r2(config-if)#no shutdown

r3(config)#int f0/0
r3(config-if)#ip address 192.168.3.2 255.255.255.0
r3(config-if)#no shutdown

r3(config-if)#int f0/1
r3(config-if)#ip address 192.168.4.1 255.255.255.0
r3(config-if)#no shutdown
==========================================================
3.配置好所有ip地址后,开启ospf协议和宣告
r1(config)#router ospf 100
r1(config-router)#network 192.168.1.0 0.0.0.255 area 0
r1(config-router)#network 192.168.2.0 0.0.0.255 area 1
r1(config-router)#exit

r2(config-if)#exit
r2(config)#router ospf 100
r2(config-router)#network 192.168.2.0 0.0.0.255 area 1
r2(config-router)#network 192.168.3.0 0.0.0.255 area 1

r3(config)#router ospf 100
r3(config-router)#network 192.168.3.0 0.0.0.255 area 1
r3(config-router)#network 192.168.4.0 0.0.0.255 area 1
r3(config-router)#exit
-----------------------------------------------------
4.查看各路由之前的邻居表
r1#show ip route

C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/1
O 192.168.3.0/24 [110/2] via 192.168.2.2, 00:04:12, FastEthernet0/1
O 192.168.4.0/24 [110/3] via 192.168.2.2, 00:02:40, FastEthernet0/1
=======================================================================
r2#show ip route

O IA 192.168.1.0/24 [110/2] via 192.168.2.1, 00:03:58, FastEthernet0/1
C 192.168.2.0/24 is directly connected, FastEthernet0/1
C 192.168.3.0/24 is directly connected, FastEthernet0/0
O 192.168.4.0/24 [110/2] via 192.168.3.2, 00:02:04, FastEthernet0/0
=======================================================================
r3#show ip route
O IA 192.168.1.0/24 [110/3] via 192.168.3.1, 00:01:01, FastEthernet0/0
O 192.168.2.0/24 [110/2] via 192.168.3.1, 00:01:01, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
C 192.168.4.0/24 is directly connected, FastEthernet0/1

===============================================================
5。客户端测试
给PC1:ip 192.168.1.10 主机位任意值
子网掩码 255.255.255.0 默认网关:192.168.1.1(路由1的0口ip地址)
PC2:IP 192.168.4.10(主机位任意值) 默认网关:192.168.4.1(路由3的1口ip地址)

PC>ping 192.168.1.10

Pinging 192.168.1.10 with 32 bytes of data:

Reply from 192.168.1.10: bytes=32 time=125ms TTL=125
Reply from 192.168.1.10: bytes=32 time=125ms TTL=125
Reply from 192.168.1.10: bytes=32 time=125ms TTL=125
Reply from 192.168.1.10: bytes=32 time=109ms TTL=125

Ping statistics for 192.168.1.10:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 109ms, Maximum = 125ms, Average = 121ms

给我留言

留言无头像?