基于单区域OSPF协议互联的公司网络搭建
1.椤圭洰鑳屾櫙
鍏徃鏈夊寳浜婚儴銆佸箍宸炲垎閮ㄥ拰涓婃捣鍒嗛儴3涓姙鍏湴鐐癸紝鍚勫垎閮ㄤ笌鎬婚儴涔嬮棿浣跨敤璺敱鍣ㄤ簰鑱斻傚叕鍙歌姹傞氳繃閰嶇疆鍗曞尯鍩烵SPF鍔ㄦ佽矾鐢憋紝瀹炵幇鍏徃涔嬮棿鑳藉浜掔浉璁块棶銆傞」鐩嫇鎵戝鍥1鎵绀猴紝鍏蜂綋瑕佹眰濡備笅锛
锛1锛夎矾鐢卞櫒R1銆丷2鍜孯3閫氳繃VPN浜掕仈锛
锛2锛塕1銆丷2鍜孯3涔嬮棿缃戠粶閫氳繃鍗曞尯鍩烵SPF鍔ㄦ佽矾鐢卞疄鐜颁簰鑱旓紱
锛3锛夋嫇鎵戞祴璇曡绠楁満鍜岃矾鐢卞櫒鐨処P涓庢帴鍙d俊鎭鎷撴墤鎵绀恒
鍥1 缃戠粶鎷撴墤鍥
鍖椾含鎬婚儴浣跨敤192.168.1.0缃戞锛屼笂娴峰垎閮ㄤ娇鐢172.16.1.0缃戞锛屽箍宸炲垎閮ㄤ娇鐢10.10.10.0缃戞锛孯1涓嶳2涔嬮棿涓20.20.20.0缃戞锛孯1涓嶳3涔嬮棿涓30.30.30.0缃戞锛孯2涓嶳3涔嬮棿涓40.40.40.0缃戞锛屾墍鏈夌綉娈靛潎浣跨敤24浣嶅瓙缃戞帺鐮併傝矾鐢卞櫒闇閰嶇疆鍗曞尯鍩烵SPF鍔ㄦ佽矾鐢憋紝浣挎墍鏈夎绠楁満鍧囪兘浜掕銆
閰嶇疆姝ラ濡備笅锛
锛1锛夐厤缃矾鐢卞櫒鎺ュ彛
锛2锛夐儴缃插崟鍖哄煙OSPF缃戠粶
锛3锛夐厤缃悇璁$畻鏈虹殑IP鍦板潃涓庣綉鍏
涓氬姟瑙勫垝濡備笅琛細
琛1 IP鍦板潃瑙勫垝琛
琛2 鎺ュ彛瑙勫垝琛
聛R1鐨勯厤缃
鈥歊2鐨勯厤缃
鈥歊3鐨勯厤缃
棣栧厛鍒涘缓骞惰繍琛孫SPF锛屾帴鐫鍒涘缓鍖哄煙骞惰繘鍏PSF鍖哄煙瑙嗗浘锛屾寚瀹氳繍琛孫SPF鍗忚鐨勬帴鍙e拰鎺ュ彛鎵灞炵殑鍖哄煙銆
聛R1鐨勯厤缃
鈥歊2鐨勯厤缃
茠R3鐨勯厤缃
PC1 IP閰嶇疆鍥
PC2 IP閰嶇疆鍥
PC3 IP閰嶇疆鍥
聛R1鐨勯厤缃
R2鐨勯厤缃
R3鐨勯厤缃
鈥淭ype鈥濅负浠ュお缃戦粯璁ょ殑骞挎挱缃戠被鍨嬶紱鈥淪tate鈥濅负璇ユ帴鍙e綋鍓嶇殑鐘舵侊紝鏄剧ず涓篋R鐘舵併
聛R1鐨勯厤缃
閫氳繃杩欐潯鍛戒护锛孯outer-ID鍙互鏌ョ湅閭诲眳鐨勮矾鐢卞櫒鏍囪瘑锛涢氳繃Address鍙互鏌ョ湅閭诲眳鐨凮SPF鎺ュ彛IP鍦板潃锛涢氳繃State鍙互鏌ョ湅鐩墠涓庤璺敱鍣ㄧ殑OSPF鐨勯偦灞呯姸鎬侊紱閫氳繃Priority鍙互鏌ョ湅褰撳墠璇ラ偦灞匫SPF鎺ュ彛鐨凞R浼樺厛绾с
聛R1鐨勯厤缃
閫氳繃姝よ矾鐢辫〃鍙互瑙傚療鍒帮紝鈥淒estination/Mask鈥濇爣璇嗕簡鐩殑缃戞鐨勫墠缂鍙婃帺鐮侊紝鈥淧roto鈥濇爣璇嗕簡姝よ矾鐢变俊鎭槸閫氳繃OSPF鍗忚鑾峰彇鐨勶紝鈥淧re鈥濇爣璇嗕簡璺敱浼樺厛绾э紝鈥淐ost鈥濇爣璇嗕簡寮閿鍊硷紝鈥淣extHop鈥濇爣璇嗕簡涓嬩竴璺冲湴鍧锛屸淚nterface鈥濇爣璇嗕簡姝ゅ墠缂鐨勫嚭鎺ュ彛銆
閫氳繃Ping鍛戒护锛屾祴璇曞悇閮ㄩ棬鍐呴儴閫氫俊鐨勬儏鍐点
浣跨敤PC1璁$畻鏈篜ing PC2鐨勮绠楁満:
浣跨敤PC1鐨勮绠楁満Ping PC3鐨勮绠楁満锛
鍏徃鏈夊寳浜婚儴銆佸箍宸炲垎閮ㄥ拰涓婃捣鍒嗛儴3涓姙鍏湴鐐癸紝鍚勫垎閮ㄤ笌鎬婚儴涔嬮棿浣跨敤璺敱鍣ㄤ簰鑱斻傚叕鍙歌姹傞氳繃閰嶇疆鍗曞尯鍩烵SPF鍔ㄦ佽矾鐢憋紝瀹炵幇鍏徃涔嬮棿鑳藉浜掔浉璁块棶銆傞」鐩嫇鎵戝鍥1鎵绀猴紝鍏蜂綋瑕佹眰濡備笅锛
锛1锛夎矾鐢卞櫒R1銆丷2鍜孯3閫氳繃VPN浜掕仈锛
锛2锛塕1銆丷2鍜孯3涔嬮棿缃戠粶閫氳繃鍗曞尯鍩烵SPF鍔ㄦ佽矾鐢卞疄鐜颁簰鑱旓紱
锛3锛夋嫇鎵戞祴璇曡绠楁満鍜岃矾鐢卞櫒鐨処P涓庢帴鍙d俊鎭鎷撴墤鎵绀恒
鍥1 缃戠粶鎷撴墤鍥
2.椤圭洰瑙勫垝璁捐
鍖椾含鎬婚儴浣跨敤192.168.1.0缃戞锛屼笂娴峰垎閮ㄤ娇鐢172.16.1.0缃戞锛屽箍宸炲垎閮ㄤ娇鐢10.10.10.0缃戞锛孯1涓嶳2涔嬮棿涓20.20.20.0缃戞锛孯1涓嶳3涔嬮棿涓30.30.30.0缃戞锛孯2涓嶳3涔嬮棿涓40.40.40.0缃戞锛屾墍鏈夌綉娈靛潎浣跨敤24浣嶅瓙缃戞帺鐮併傝矾鐢卞櫒闇閰嶇疆鍗曞尯鍩烵SPF鍔ㄦ佽矾鐢憋紝浣挎墍鏈夎绠楁満鍧囪兘浜掕銆
閰嶇疆姝ラ濡備笅锛
锛1锛夐厤缃矾鐢卞櫒鎺ュ彛
锛2锛夐儴缃插崟鍖哄煙OSPF缃戠粶
锛3锛夐厤缃悇璁$畻鏈虹殑IP鍦板潃涓庣綉鍏
涓氬姟瑙勫垝濡備笅琛細
琛1 IP鍦板潃瑙勫垝琛
璁惧 | 鎺ュ彛 | IP鍦板潃 |
R1 | G0/0/0 | 192.168.1.2/24 |
R1 | G0/0/1 | 20.20.20.1/24 |
R1 | G0/0/2 | 30.30.30.1/24 |
R2 | G0/0/0 | 172.16.1.2/24 |
R2 | G0/0/1 | 20.20.20.2/24 |
R2 | G0/0/2 | 40.40.40.1/24 |
R3 | G0/0/0 | 10.10.10.2/24 |
R3 | G0/0/1 | 40.40.40.2/24 |
R3 | G0/0/2 | 30.30.30.2/24 |
琛2 鎺ュ彛瑙勫垝琛
鏈璁惧 | 鎺ュ彛 | 绔彛IP鍦板潃 | 瀵圭璁惧 |
R1 | G0/0/0 | 192.168.1.2/24 | PC1 |
R1 | G0/0/1 | 20.20.20.1/24 | R2 |
R1 | G0/0/2 | 30.30.30.1/24 | R3 |
R2 | G0/0/0 | 172.16.1.2/24 | PC2 |
R2 | G0/0/1 | 20.20.20.2/24 | R1 |
R2 | G0/0/2 | 40.40.40.2/24 | R3 |
R3 | G0/0/0 | 10.10.10.2/24 | PC3 |
R3 | G0/0/1 | 40.40.40.1/24 | R2 |
R3 | G0/0/2 | 30.30.30.2/24 | R1 |
3.椤圭洰瀹炴柦
锛1锛夐厤缃矾鐢卞櫒鎺ュ彛
聛R1鐨勯厤缃
[Huawei]system-view [Huawei]sysname R1 [R1]interface GigabitEthernet 0/0/0 [R1-GigabitEthernet0/0/0]ip address 192.168.1.2 255.255.255.0 [R1]interface GigabitEthernet 0/0/1 [R1-GigabitEthernet0/0/1]ip address 20.20.20.1 255.255.255.0 [R1]interface GigabitEthernet 0/0/2 [R1-GigabitEthernet0/0/2]ip address 30.30.30.1 255.255.255.0 |
鈥歊2鐨勯厤缃
[Huawei]system-view [Huawei]sysname R2 [R2]interface GigabitEthernet 0/0/0 [R2-GigabitEthernet0/0/0]ip address 172.16.1.2 255.255.255.0 [R2]interface GigabitEthernet 0/0/1 [R2-GigabitEthernet0/0/1]ip address 20.20.20.2 255.255.255.0 [R2]interface GigabitEthernet 0/0/2 [R2-GigabitEthernet0/0/2]ip address 40.40.40.2 255.255.255.0 |
鈥歊3鐨勯厤缃
[Huawei]system-view [Huawei]sysname R3 [R3]interface GigabitEthernet 0/0/0 [R3-GigabitEthernet0/0/0]ip address 10.10.10.2 255.255.255.0 [R3]interface GigabitEthernet 0/0/1 [R3-GigabitEthernet0/0/1]ip address 40.40.40.1 255.255.255.0 [R3]interface GigabitEthernet 0/0/2 [R3-GigabitEthernet0/0/2]ip address 30.30.30.2 255.255.255.0 |
锛2锛夐儴缃插崟鍖哄煙OSPF缃戠粶
棣栧厛鍒涘缓骞惰繍琛孫SPF锛屾帴鐫鍒涘缓鍖哄煙骞惰繘鍏PSF鍖哄煙瑙嗗浘锛屾寚瀹氳繍琛孫SPF鍗忚鐨勬帴鍙e拰鎺ュ彛鎵灞炵殑鍖哄煙銆
聛R1鐨勯厤缃
[R1]ospf 1 [R1-ospf-1]area 0 [R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 [R1-ospf-1-area-0.0.0.0]network 20.20.20.0 0.0.0.255 [R1-ospf-1-area-0.0.0.0]network 30.30.30.0 0.0.0.255 |
鈥歊2鐨勯厤缃
[R2]ospf 1 [R2-ospf-1]area 0 [R2-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]network 20.20.20.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]network 40.40.40.0 0.0.0.255 |
茠R3鐨勯厤缃
[R3]ospf 1 [R3-ospf-1]area 0 [R3-ospf-1-area-0.0.0.0]network 10.10.10.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]network 40.40.40.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]network 30.30.30.0 0.0.0.255 |
锛3锛夐厤缃悇璁$畻鏈虹殑IP鍦板潃
PC1 IP閰嶇疆鍥
PC2 IP閰嶇疆鍥
PC3 IP閰嶇疆鍥
4.椤圭洰楠岃瘉
锛1锛夐獙璇丱SPF鎺ュ彛閫氬憡
聛R1鐨勯厤缃
[R1]displayospfinterface
OSPFProcess 1 withRouterID 192.168.1.2
Interfaces
Area: 0.0.0.0 (MPLSTEnotenabled)
IPAddressTypeStateCostPriDRBDR
192.168.1.2BroadcastDR 1 1 192.168.1.2 0.0.0.0
20.20.20.1BroadcastDR 1 1 20.20.20.1 20.20.20.2
30.30.30.1BroadcastDR 1 1 30.30.30.1 30.30.30
R2鐨勯厤缃
[R2]displayospfinterface
OSPFProcess 1 withRouterID 172.16.1.2
Interfaces
Area: 0.0.0.0 (MPLSTEnotenabled)
IPAddressTypeStateCostPriDRBDR
172.16.1.2BroadcastDR 1 1 172.16.1.2 0.0.0.0
20.20.20.2BroadcastBDR 1 1 20.20.20.1 20.20.20.2
40.40.40.1BroadcastDR 1 1 40.40.40.1 40.40.40.2
R3鐨勯厤缃
[R3]displayospfinterface
OSPFProcess 1 withRouterID 10.10.10.2
Interfaces
Area: 0.0.0.0 (MPLSTEnotenabled)
IPAddressTypeStateCostPriDRBDR
10.10.10.2BroadcastDR 1 1 10.10.10.2 0.0.0.0
40.40.40.2BroadcastBDR 1 1 40.40.40.1 40.40.40.2
30.30.30.2BroadcastBDR 1 1 30.30.30.1 30.30.30.2
鈥淭ype鈥濅负浠ュお缃戦粯璁ょ殑骞挎挱缃戠被鍨嬶紱鈥淪tate鈥濅负璇ユ帴鍙e綋鍓嶇殑鐘舵侊紝鏄剧ず涓篋R鐘舵併
锛2锛夋煡鐪婳SPF閭诲眳鐘舵
聛R1鐨勯厤缃
[R1]displayospf peer
OSPFProcess 1 with Router ID 192.168.1.2
Neighbors
Area0.0.0.0 interface 20.20.20.1(GigabitEthernet0/0/1)'s neighbors
RouterID: 172.16.1.2 Address: 20.20.20.2
State: Full Mode:Nbr is Slave Priority: 1
DR: 20.20.20.1 BDR: 20.20.20.2 MTU: 0
Deadtimer due in 37 sec
Retranstimer interval: 5
Neighboris up for 00:44:40
AuthenticationSequence: [ 0 ]
Neighbors
Area0.0.0.0 interface 30.30.30.1(GigabitEthernet0/0/2)'s neighbors
RouterID: 10.10.10.2 Address: 30.30.30.2
State: Full Mode:Nbr is Slave Priority: 1
DR: 30.30.30.1 BDR: 30.30.30.2 MTU: 0
Deadtimer due in 37 sec
Retranstimer interval: 5
Neighboris up for 00:42:48
AuthenticationSequence: [ 0 ]
閫氳繃杩欐潯鍛戒护锛孯outer-ID鍙互鏌ョ湅閭诲眳鐨勮矾鐢卞櫒鏍囪瘑锛涢氳繃Address鍙互鏌ョ湅閭诲眳鐨凮SPF鎺ュ彛IP鍦板潃锛涢氳繃State鍙互鏌ョ湅鐩墠涓庤璺敱鍣ㄧ殑OSPF鐨勯偦灞呯姸鎬侊紱閫氳繃Priority鍙互鏌ョ湅褰撳墠璇ラ偦灞匫SPF鎺ュ彛鐨凞R浼樺厛绾с
锛3锛夋煡鐪婳SPF璺敱琛
聛R1鐨勯厤缃
[R1]displayip routing-table protocol ospf
RouteFlags: R - relay, D - download to fib
------------------------------------------------------------------------------
Publicrouting table : OSPF
Destinations : 3 Routes : 4
OSPFrouting table status : <Active>
Destinations : 3 Routes : 4
Destination/MaskProto Pre Cost Flags NextHop Interface
10.10.10.0/24OSPF 10 2 D 30.30.30.2 GigabitEthernet0/0/2
40.40.40.0/24OSPF 10 2 D 20.20.20.2 GigabitEthernet0/0/1
OSPF10 2 D 30.30.30.2 GigabitEthernet0/0/2
172.16.1.0/24OSPF 10 2 D 20.20.20.2 GigabitEthernet0/0/1
OSPFrouting table status : <Inactive>
Destinations : 0 Routes : 0
閫氳繃姝よ矾鐢辫〃鍙互瑙傚療鍒帮紝鈥淒estination/Mask鈥濇爣璇嗕簡鐩殑缃戞鐨勫墠缂鍙婃帺鐮侊紝鈥淧roto鈥濇爣璇嗕簡姝よ矾鐢变俊鎭槸閫氳繃OSPF鍗忚鑾峰彇鐨勶紝鈥淧re鈥濇爣璇嗕簡璺敱浼樺厛绾э紝鈥淐ost鈥濇爣璇嗕簡寮閿鍊硷紝鈥淣extHop鈥濇爣璇嗕簡涓嬩竴璺冲湴鍧锛屸淚nterface鈥濇爣璇嗕簡姝ゅ墠缂鐨勫嚭鎺ュ彛銆
锛4锛夋祴璇曞悇閮ㄩ棬璁$畻鏈虹殑浜掗氭
閫氳繃Ping鍛戒护锛屾祴璇曞悇閮ㄩ棬鍐呴儴閫氫俊鐨勬儏鍐点
浣跨敤PC1璁$畻鏈篜ing PC2鐨勮绠楁満:
PC>ping 172.16.1.1 Ping 172.16.1.1: 32 data bytes, Press Ctrl_C to break From 172.16.1.1: bytes=32 seq=1 ttl=126 time=16 ms From 172.16.1.1: bytes=32 seq=2 ttl=126 time=15 ms From 172.16.1.1: bytes=32 seq=3 ttl=126 time=16 ms From 172.16.1.1: bytes=32 seq=4 ttl=126 time=31 ms From 172.16.1.1: bytes=32 seq=5 ttl=126 time=16 ms --- 172.16.1.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 15/18/31 ms |
浣跨敤PC1鐨勮绠楁満Ping PC3鐨勮绠楁満锛
PC>ping 10.10.10.1 Ping 10.10.10.1: 32 data bytes, Press Ctrl_C to break From 10.10.10.1: bytes=32 seq=1 ttl=126 time=16 ms From 10.10.10.1: bytes=32 seq=2 ttl=126 time=16 ms From 10.10.10.1: bytes=32 seq=3 ttl=126 time=15 ms From 10.10.10.1: bytes=32 seq=4 ttl=126 time=32 ms From 10.10.10.1: bytes=32 seq=5 ttl=126 time=15 ms --- 10.10.10.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 15/18/32 ms |