拓撲如上:
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)#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#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
驗證在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(config)#hostname R2
R1(config-if)#ip address 192.168.2.254 255.255.255.0
R1(config-if)#ip address 12.1.1.2 255.255.255.0
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
檢視鄰居表:
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
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
驗證在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:
Minimum = 30ms, Maximum = 48ms, Average = 38ms
總結:
1、使用區域的概念,有效的減少路由選擇協定對cpu和記憶體的占用。還可以降低路由選擇協定的通信量。
2、完全無類别的處理位址問題。
3、支援無類别。vlsm和超網技術。
4、支援無大小限制的、任意的路徑成本。(cost=預設是10的8次方[參考帶寬]/ 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,如需轉載請自行聯系原作者