OSPF单区域配置

   由于EIGRP协议是私有的,只支持cisco的设备,所以现在社会流行的还是OSPF协议,他支持各种不同的设备互联。 

OSPF(Open Shortest Path First开放式最短路径优先)是一个内部网关协议(Interior Gateway Protocol,简称IGP),用于在单一自治系统(autonomous system,AS)内决策路由。与RIP相比,OSPF是链路状态路由协议,而RIP是距离矢量路由协议。OSPF的协议管理距离(AD)是110。

还是先说一下OSPF的优点。

1.对网络发生的变化能够快速响应。

2.当网络发生变化的时候发生触发性更新。

3.支持VLSM

4.方便管理

OSPF协议有3表

1.邻居表:邻居路由器的信息。(show ip ospf  neighbor 查看邻居表信息)

2.拓扑表:也叫链路状态数据库。(show ip ospf database查看链路状态)

3.路由表:到达目标网络的最佳路径。(show ip rou 查看路由表)

 

OSPF引入了区域的概念,区域分2种:
1.骨干区域(area 0)
2.常规区域
注意,所有的常规区域必须和骨干区域相连

相关配置请看下面拓扑图与命令。

 

 

 

R0配置如下:

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int f0/0
Router(config-if)#ip add 192.168.12.1 255.255.255.0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
int lo 0

%LINK-5-CHANGED: Interface Loopback0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up

Router(config-if)#ip add 1.1.1.1 255.255.255.0
Router(config-if)#ex
Router(config)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Router(config)#
Router(config)#rou
Router(config)#router os
Router(config)#router os 1
Router(config-router)#rou
Router(config-router)#router-id 10.10.10.10 (这是给路由器起的名字,在OSPF邻居表中可见)
Router(config-router)#network 1.1.1.0 0.0.0.255 area 0
Router(config-router)#network 192.168.12.0 0.0.0.255 area 0
Router(config-router)#end

Router#
%SYS-5-CONFIG_I: Configured from console by console

R1配置如下:

Router>
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int f0/0
Router(config-if)#ip add 192.168.12.2 255.255.255.0
Router(config-if)#no sh

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Router(config-if)#
Router(config-if)#
Router(config-if)#int f0/1
Router(config-if)#ip add 192.168.23.2 255.255.255.0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

Router(config-if)#
Router(config-if)#ex
Router(config)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

Router(config)#router os
Router(config)#router ospf 1
 Router(config-router)#router-id 20.20.20.20
Router(config-router)#network 192.168.23.0 0.0.0.255 area 0
Router(config-router)#network 192.168.12.0 0.0.0.255 area 0

R2配置如下:

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int f0/0
Router(config-if)#ip add 192.168.23.3 255.255.255.0
Router(config-if)#no sh

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Router(config-if)#
Router(config-if)#
Router(config-if)#int f0/1 
Router(config-if)#ip add 192.168.34.3 255.255.255.0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

Router(config-if)#ex
Router(config)#router ospf 1
Router(config-router)#rou
Router(config-router)#router-id 30.30.30.30
Router(config-router)#network 192.168.34.0 0.0.0.255 area 0
Router(config-router)#network 192.168.23.0 0.0.0.255 area 0

R3配置如下:

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int lo 0

%LINK-5-CHANGED: Interface Loopback0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up

Router(config-if)#ip add 4.4.4.4 255.255.255.0
Router(config-if)#int f0/0
Router(config-if)#ip add 192.168.34.4 255.255.255.0
Router(config-if)#no sh

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Router(config-if)#ex
Router(config)#router os
Router(config)#router ospf 1
Router(config-router)#rou
Router(config-router)#router-id 40.40.40.40
Router(config-router)#ne
Router(config-router)#network 4.4.4.0 0.0.0.255 area 0
Router(config-router)#network 192.168.34.0 0.0.0.255 area 0

然后查看路由表互相PING下,看是否全网互通。

多多交流,多多指点!

你可能感兴趣的:(职场,休闲,ospf,OSPF配置,OSPF优点)