CCNA--LAB-4:配置OSPF路由协议

CCNA--LAB-4:配置OSPF路由协议
拓扑如上:
 
R1:
Router>en
Router#conf t
Router(config)#hostname R1
R1(config)#interface f0/0
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int f0/1
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exit
R1(config)#router ospf 1     --进入OSPF配置模式,进程号为1
R1(config-router)#router-id 1.1.1.1     --路由器ID为1.1.1.1
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0     --发布直连网络,反掩码,区域号(注:OSPF必需有骨干区域,为区域0)
R1(config-router)#network 12.1.1.0 0.0.0.255 area 0     --发布直连网络,反掩码,区域号
R1(config-router)#end
R1#

查看OSPF邻居表:
R1#show ip ospf neighbor
Neighbor ID     Pri     State           Dead Time   Address         Interface
2.2.2.2           1     FULL/DR         00:00:38    12.1.1.2        FastEthernet0/1
邻居ID号//   优先级//   状态//          死亡时间//  对端地址//      通过F0/1接口建立//
R1#

查看路由表:
R1#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
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
O    192.168.2.0/24 [110/2] via 12.1.1.2, 00:00:20, FastEthernet0/1
R1#

验证在PC0拼PC1:
PC>ping 192.168.2.1
Pinging 192.168.2.1 with 32 bytes of data:
Reply from 192.168.2.1: bytes=32 time=48ms TTL=126
Reply from 192.168.2.1: bytes=32 time=33ms TTL=126
Reply from 192.168.2.1: bytes=32 time=32ms TTL=126
Reply from 192.168.2.1: bytes=32 time=38ms TTL=126
Ping statistics for 192.168.2.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 32ms, Maximum = 48ms, Average = 37ms
PC>
 
 
 
 
R2:
Router>en
Router#conf t
Router(config)#hostname R2
R1(config)#interface f0/0
R1(config-if)#ip address 192.168.2.254 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int f0/1
R1(config-if)#ip address 12.1.1.2 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exit
R1(config)#router ospf 1
R1(config-router)#router-id 2.2.2.2
R1(config-router)#network 192.168.2.0 0.0.0.255 area 0
R1(config-router)#network 12.1.1.0 0.0.0.255 area 0
R1(config-router)#end
R1#

查看邻居表:
R2#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/BDR        00:00:38    12.1.1.1        FastEthernet0/1
R2#
 
查看路由表:
R2#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
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/1
O    192.168.1.0/24 [110/2] via 12.1.1.1, 00:03:08, FastEthernet0/1
C    192.168.2.0/24 is directly connected, FastEthernet0/0
R2#

验证在PC1拼PC0:
PC>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time=48ms TTL=126
Reply from 192.168.1.1: bytes=32 time=30ms TTL=126
Reply from 192.168.1.1: bytes=32 time=37ms TTL=126
Reply from 192.168.1.1: bytes=32 time=40ms TTL=126
Ping statistics for 192.168.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 30ms, Maximum = 48ms, Average = 38ms
PC>

 
总结:
1、使用区域的概念,有效的减少路由选择协议对cpu和内存的占用。还可以降低路由选择协议的通信量。
2、完全无类别的处理地址问题。
3、支持无类别。vlsm和超网技术。
4、支持无大小限制的、任意的度量值。(cost=默认是108次方[参考带宽]/ BW[接口配置带宽]
5、支持多条路径的高效率的等价负载均衡。(默认4条,最多6条)
6、使用保留的组播地址来减小对不宣告OSPF报文的设备的影响。(DR Others 224.0.0.5 DR:224.0.0.6
7、支持更安全的路由选择认证。(null、明文、md5
8、使用可跟踪外部路由的路由标记。(E1/E2 默认为E2忽略内部的开销值)
 









本文转自 meiyanaa 51CTO博客,原文链接:http://blog.51cto.com/justim/234968,如需转载请自行联系原作者
上一篇:阿里云服务器Java相关环境搭建的过程


下一篇:阿里云主机(VPS主机)上搭建Anki服务器及Anki服务器搭建方案分析