目录
一、相关知识
1、基本配置命令
2、OSPF为什么是无自环的?
3、何时需要运行OSPF协议
二、拓扑图
三、配置命令
1、ZY-R-A路由配置命令
2、ZY-R-B路由配置命令
3、ZY-R-C路由配置命令
四、验证过程
一、相关知识
1、基本配置命令
配置路由器的Router ID:[Quidway]router id A.B.C.D
启动OSPF协议:[Quidway] ospf [ process-id ]
配置OSPF区域:[Quidway-ospf-1]area area-id
在指定网段使用ospf:[Quidway-ospf-1-area-0.0.0.0] network ip-address wildcard-mask
2、OSPF为什么是无自环的?
每一条LSA(链路状态广播)都标记了生成者(用生成该LSA的路由器的Router ID标记),其它路由器只负责传输。这样不会在传输的过程中发生对该信息的改变或错误理解
路由计算的算法是SPF算法。计算的结果是一棵树,路由是树上的叶子节点。从根节点到叶子节点是单向不可回复的路径
3、何时需要运行OSPF协议
网络的规模:网络中的路由器在10台以上;中等或大规模的网络。
网络的拓扑结构:网络的拓扑结构为网状,并且任意两台路由器之间都互通的需求。
其它特殊的需求:要求路由变化时能够快速收敛,要求路由协议自身的网络开销尽量降低。
对路由器自身的要求:运行OSPF协议时对路由器的CPU的处理能力及内存的大小都有一定的要求,性能很低的路由器不推荐使用OSPF协议。
二、拓扑图
三、配置命令
1、ZY-R-A路由配置命令
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname ZY-R-A
ZY-R-A(config)#interface loopback 0
ZY-R-A(config-if)#ip address 172.16.10.1 255.255.255.0
ZY-R-A(config-if)#no shutdown
ZY-R-A(config-if)#exit
ZY-R-A(config)#interface fastEthernet 0/0
ZY-R-A(config-if)#ip address 192.168.20.1 255.255.255.0
ZY-R-A(config-if)#no shutdown
ZY-R-A(config-if)#exit
ZY-R-A(config)#router ospf 100
ZY-R-A(config-router)#router-id 1.1.1.1
ZY-R-A(config-router)#network 172.16.10.0 0.0.0.255 area 1
ZY-R-A(config-router)#network 192.168.20.0 0.0.0.255 area 0
2、ZY-R-B路由配置命令
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname ZY-R-B
ZY-R-B(config)#interface fastEthernet 0/0
ZY-R-B(config-if)#ip address 192.168.20.2 255.255.255.0
ZY-R-B(config-if)#no shutdown
ZY-R-B(config-if)#exit
ZY-R-B(config)#interface fastEthernet 0/1
ZY-R-B(config-if)#ip address 192.168.30.1 255.255.255.0
ZY-R-B(config-if)#no shutdown
ZY-R-B(config-if)#exit
ZY-R-B(config)#router ospf 100
ZY-R-B(config-router)#router-id 2.2.2.2
ZY-R-B(config-router)#network 192.168.20.0 0.0.0.255 area 0
ZY-R-B(config-router)#network 192.168.30.0 0.0.0.255 area 0
3、ZY-R-C路由配置命令
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname ZY-R-C
ZY-R-C(config)#interface loopback 0
ZY-R-C(config-if)#ip address 10.10.10.1 255.255.255.0
ZY-R-C(config-if)#no shutdown
ZY-R-C(config-if)#exit
ZY-R-C(config)#interface fastEthernet 0/1
ZY-R-C(config-if)#ip address 192.168.30.2 255.255.255.0
ZY-R-C(config-if)#no shutdown
ZY-R-C(config-if)#exit
ZY-R-C(config)#router ospf 100
ZY-R-C(config-router)#router-id 3.3.3.3
ZY-R-C(config-router)#network 192.168.30.0 0.0.0.255 area 0
ZY-R-C(config-router)#network 10.10.10.0 0.0.0.255 area 2
四、验证过程
Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname ZY-R-A ZY-R-A(config)#interface loopback 0 ZY-R-A(config-if)#ip address 172.16.10.1 255.255.255.0 ZY-R-A(config-if)#no shutdown ZY-R-A(config-if)#exit ZY-R-A(config)#interface fastEthernet 0/0 ZY-R-A(config-if)#ip address 192.168.20.1 255.255.255.0 ZY-R-A(config-if)#no shutdown ZY-R-A(config-if)#exit ZY-R-A(config)#router ospf 100 ZY-R-A(config-router)#router-id 1.1.1.1 ZY-R-A(config-router)#network 172.16.10.0 0.0.0.255 area 1 ZY-R-A(config-router)#network 192.168.20.0 0.0.0.255 area 0
2、ZY-R-B路由配置命令
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname ZY-R-B
ZY-R-B(config)#interface fastEthernet 0/0
ZY-R-B(config-if)#ip address 192.168.20.2 255.255.255.0
ZY-R-B(config-if)#no shutdown
ZY-R-B(config-if)#exit
ZY-R-B(config)#interface fastEthernet 0/1
ZY-R-B(config-if)#ip address 192.168.30.1 255.255.255.0
ZY-R-B(config-if)#no shutdown
ZY-R-B(config-if)#exit
ZY-R-B(config)#router ospf 100
ZY-R-B(config-router)#router-id 2.2.2.2
ZY-R-B(config-router)#network 192.168.20.0 0.0.0.255 area 0
ZY-R-B(config-router)#network 192.168.30.0 0.0.0.255 area 0
3、ZY-R-C路由配置命令
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname ZY-R-C
ZY-R-C(config)#interface loopback 0
ZY-R-C(config-if)#ip address 10.10.10.1 255.255.255.0
ZY-R-C(config-if)#no shutdown
ZY-R-C(config-if)#exit
ZY-R-C(config)#interface fastEthernet 0/1
ZY-R-C(config-if)#ip address 192.168.30.2 255.255.255.0
ZY-R-C(config-if)#no shutdown
ZY-R-C(config-if)#exit
ZY-R-C(config)#router ospf 100
ZY-R-C(config-router)#router-id 3.3.3.3
ZY-R-C(config-router)#network 192.168.30.0 0.0.0.255 area 0
ZY-R-C(config-router)#network 10.10.10.0 0.0.0.255 area 2
四、验证过程
Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname ZY-R-C ZY-R-C(config)#interface loopback 0 ZY-R-C(config-if)#ip address 10.10.10.1 255.255.255.0 ZY-R-C(config-if)#no shutdown ZY-R-C(config-if)#exit ZY-R-C(config)#interface fastEthernet 0/1 ZY-R-C(config-if)#ip address 192.168.30.2 255.255.255.0 ZY-R-C(config-if)#no shutdown ZY-R-C(config-if)#exit ZY-R-C(config)#router ospf 100 ZY-R-C(config-router)#router-id 3.3.3.3 ZY-R-C(config-router)#network 192.168.30.0 0.0.0.255 area 0 ZY-R-C(config-router)#network 10.10.10.0 0.0.0.255 area 2
四、验证过程



