GRE ×××

GRE ××× :

這種×××並不存在安全性 因此一般應該使用的是GRE over IPsec ×××

Tunnel 源指定爲本地網關公網的接口或IP tunnel目標指定爲對端網關的公網接口IP

其實就是私網的數據包封裝一層公網IP頭部而已。

原理: 公網IP + GRE頭(tunnel IP+私網IP數據 (三層IP包頭)

 

封裝GRE頭部,GRE頭部4byte。再加私網頭部20byte,並在外部封裝公網IP以穿越R2-R5-R3(公網)。就相當於給分公司到總公司的數據包打了2IP頭部,即IPinIP

R2R3上我們分別定義了一個tunnel 0口,私網的數據包到達R2,R3時,會被髮送至tunnel 0中,並進行二次封裝封裝公網IPR2R3公網出口IP。從而使數據包在公網中穿越,此時數據包具備雙層IP頭部。當到達對端的出口路由器時,會嘗試解封裝掉公網頭部。從而露出私網頭部,路由器檢查這層私網IP頭部的IP源目的IP地址,並查找有關其目標相關的路由條目,檢查到後,會直接對數據進行轉發。

 

R1--R2—R5--R3----R4

R1 爲分公司

R4 爲總公司

R2 爲分公司的出口路由器

R3 爲總公司的出口路由器

模擬公網 R5

網絡拓撲如下:

clip_p_w_picpath021

 

 

 

首先保證網絡的連通性,這是必須的!!!        

R1: 分公司

#        
version 5.20, Alpha 1011          
#          
sysname RT1          

interface Ethernet0/0/0          
undo shut          
port link-mode route          
ip address 192.168.1.1 255.255.255.0          
#          
ip route-static 0.0.0.0 0.0.0.0 192.168.1.2
指一條默認路由        

user-interface con 0          
idle-timeout 0 0            
user-interface vty 0 4            
#            
return

R2: 分公司出口路由器

version 5.20, Alpha 1011        
#          
sysname RT2          

interface Ethernet0/0/0          
undo shut          
port link-mode route          
ip address 192.168.1.2 255.255.255.0          
#          
interface Serial0/2/0          
undo shut          
link-protocol ppp          
ip address 172.16.1.1 255.255.255.0          
#          
interface Tunnel0          
undo shut          
ip address 10.1.1.1 255.255.255.0          
source Serial0/2/0          
destination 172.16.2.2          
#          
ip route-static 0.0.0.0 0.0.0.0 172.16.1.2
指一條到Internet的默認路由        
ip route-static 192.168.2.0 255.255.255.0 Tunnel0 (
指一條下一跳爲tunnel 0,目的地址爲目標網絡號的靜態路由)將數據從隧道中發過去
       
user-interface con 0          
idle-timeout 0 0            
user-interface vty 0 4            
#            
return

R5: 模擬的公網

#        
version 5.20, Alpha 1011          
#          
sysname RT5          
interface Serial0/2/0          
undo shut          
link-protocol ppp          
ip address 172.16.1.2 255.255.255.0          
#          
interface Serial0/2/1          
link-protocol ppp          
ip address 172.16.2.1 255.255.255.0          
#          
user-interface con 0          
idle-timeout 0 0          
user-interface vty 0 4          
#          
return

R3: 總公司的出口路由器

version 5.20, Alpha 1011        
#          
sysname RT3          
interface Serial0/2/0          
undo shut          
link-protocol ppp          
ip address 172.16.2.2 255.255.255.0          
#          
interface Serial0/2/1          
undo shut          
link-protocol ppp          
ip address 192.168.2.1 255.255.255.0          

interface Tunnel0          
undo shut          
ip address 10.1.1.2 255.255.255.0          
source Serial0/2/0          
undo shut          
destination 172.16.1.1          
#          
ip route-static 0.0.0.0 0.0.0.0 172.16.2.1
指一條到Internet的默認路由        
ip route-static 192.168.1.0 255.255.255.0 Tunnel0 (
指一條下一跳爲tunnel 0,目的地址爲目標網絡號的靜態路由)將數據從隧道中發過去
       

user-interface con 0          
idle-timeout 0 0            
user-interface vty 0 4            
#            
return

 

R4: 總公司

version 5.20, Alpha 1011        
#          
sysname RT4          
#          
interface Serial0/2/0          
undo shut          
link-protocol ppp          
ip address 192.168.2.2 255.255.255.0          

ip route-static 0.0.0.0 0.0.0.0 192.168.2.1
指一條默認路由        

user-interface con 0          
idle-timeout 0 0            
user-interface vty 0 4            
#            
return
       

說明:

因爲 R1 R4分別模擬的是分公司和總公司

R2爲分公司的出口路由器 R3爲總公司的出口路由 因此需要分別指定一條靜態路由

R5模擬的是公網

需要在R1R4上分別指一條默認路由,以其相鄰的路由器接口爲下一跳。

R3R4上分別指定對端私有網段爲目標地址,tunnel 0口爲下一跳,寫一條靜態路由。使分公司內網和總公司內網之間的流量走R2R3之間建立起來的隧道。

 

 

 

H3C路由器上debug GREICMP得到的信息:

Debug命令:

Terminal debugging

Terminal monitor

Debugging ip packet

Debugging ip icmp

Debugging gre packet

Debugging gre error

Debugging gre all

R4 ping R1得出以下debug信息:

 

*Feb 18 17:24:15:454 2012 RT2 GRE/7/debug:Gre packet has been sent to ip queue successfully.

*Feb 18 17:24:15:454 2012 RT2 IPFWD/7/debug_case:

Receiving, interface = Tunnel0, version = 4, headlen = 20, tos = 0,

pktlen = 84, pktid = 96, offset = 0, ttl = 254, protocol = 1,

checksum = 14325, s = 192.168.2.2, d = 192.168.1.1

prompt: Receiving IP packet from Tunnel0

 

*Feb 18 17:24:15:454 2012 RT2 IPFWD/7/debug_case:

Sending, interface = Ethernet0/0/0, version = 4, headlen = 20, tos = 0,

pktlen = 84, pktid = 96, offset = 0, ttl = 253, protocol = 1,

checksum = 14581, s = 192.168.2.2, d = 192.168.1.1

prompt: Sending the packet from Tunnel0 at Ethernet0/0/0

 

*Feb 18 17:24:15:454 2012 RT2 IPFWD/7/debug_case:

Receiving, interface = Ethernet0/0/0, version = 4, headlen = 20, tos = 0,

pktlen = 84, pktid = 104, offset = 0, ttl = 255, protocol = 1,

checksum = 14061, s = 192.168.1.1, d = 192.168.2.2

prompt: Receiving IP packet from Ethernet0/0/0

 

*Feb 18 17:24:15:454 2012 RT2 IPFWD/7/debug_case:

Sending, interface = Tunnel0, version = 4, headlen = 20, tos = 0,

pktlen = 84, pktid = 104, offset = 0, ttl = 254, protocol = 1,

checksum = 14317, s = 192.168.1.1, d = 192.168.2.2

prompt: Sending the packet from Ethernet0/0/0 at Tunnel0

 

*Feb 18 17:24:15:454 2012 RT2 GRE/7/debug:

Tunnel0 packet:Before encapsulation,

Outer packet header 192.168.1.1->192.168.2.2(length = 84)

*Feb 18 17:24:15:454 2012 RT2 GRE/7/debug:

Tunnel0 packet:After encapsulation,

Outgoing packet header 172.16.1.1->172.16.2.2(length = 108)

*Feb 18 17:24:15:454 2012 RT2 GRE/7/debug:Output: Gre packet has been fast-switched successfully, interface index is 0x2f0000.

 

GRE Tunnel只支持路由器,不支持集中器和PIXASA

GRE支持IP ,IPX等協議。

GRE支持P2P GRE multipoint GRE

P2P GRE只能在2臺路由器之間建立。

MGRE 可以在多臺路由器上建立。

P2P GRE 支持IP 單播,組播及IGP 動態路由協議和非IP協議。

MGRE 只支持單播,組播以及動態IGP路由協議,不支持非IP協議。

 

要求:本源地址有效,隧道起始和重點的路由可達時,隧道接口才能UP

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章