本文為大家詳細描述了路由器上配置GRE的基本方法和詳細步驟,給出了一種GRE基本的配置案例。
1. 組網需求
執行ip 協議的兩個子網group1 和group2,通過在secpath1 和secpath2 之間使用三層隧道協議gre 實現互聯。
2. 組網圖
3. 配置步驟
(1) 配置secpath1
# 配置介面ethernet0/0/0。
[h3c] interface ethernet 0/0/0
[h3c-ethernet0/0/0] ip address
[h3c-ethernet0/0/0] quit
# 配置介面ethernet1/0/0(隧道的實際物理介面)。
[h3c] interface ethernet 1/0/0
[h3c-ethernet1/0/0] ip address
[h3c-ethernet1/0/0] quit
# 建立tunnel1 介面。
[h3c] interface tunnel 1
# 配置tunnel1 介面的ip 地址。
[h3c-tunnel1] ip address
# 配置tunnel 封裝模式。
[h3c-tunnel1] tunnel-protocol gre
# 配置tunnel1 介面的源地址(ethernet1/0/0 的ip 地址)。
[h3c-tunnel1] source
# 配置tunnel1 介面的目的'地址(secpath2 的ethernet2/0/1 的ip 地址)。
[h3c-tunnel1] destination
[h3c-tunnel1] quit
# 配置從secpath1 經過tunnel1 介面到group2 的靜態路由。
[h3c] ip route-static tunnel 1
(2) 配置secpath2
# 配置介面ethernet0/0/0。
[h3c] interface ethernet 0/0/0
[h3c-ethernet0/0/0] ip address
[h3c-ethernet0/0/0] quit
# 配置介面ethernet2/0/1(隧道的實際物理介面)。
[h3c] interface ethernet 2/0/1
[h3c-ethernet2/0/1] ip address
[h3c-ethernet2/0/1] quit
# 建立tunnel2 介面。
[h3c] interface tunnel 2
# 配置tunnel2 介面的ip 地址。
[h3c-tunnel2] ip address
# 配置tunnel 封裝模式。
[h3c-tunnel2] tunnel-protocol gre
# 配置tunnel2 介面的源地址(ethernet2/0/1 的ip 地址)。
[h3c-tunnel2] source
# 配置tunnel2 介面的目的地址(secpath1 的ethernet1/0/0 的ip 地址)。
[h3c-tunnel2] destination
[h3c-tunnel2] quit
# 配置從secpath2 經過tunnel2 介面到group1 的靜態路由。
[h3c] ip route-static tunnel 2
interface Tunnel0
tunnel source
tunnel destination
tunnel key 0
tunnel checksum
用以上例子為例,假設本端路由器
eth0:(連線內部區域網)
tunnel0:()
serial0:(連線Internet)
ip route
對端路由器
eth0:(連線內部區域網)
tunnel0:()
serial0:(連線Internet)
ip route
本端局域網裡的主機發一個報文給:報文為{SA:10.1.12,DA:}
首先該報文會發給PC閘道器,即“本端路由器”,路由器根據目的地址路由,發現需要從tunnel0口發出,做GRE封裝後,報文為{SA:,DA:,{原來報文}},然後實際上從Serial0口發出,經過Internet上的N個路由器後到達“對端路由器”,路由器解開GRE封裝恢復原來報文,再從eth0口發出去。