本文为大家详细描述了路由器上配置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口发出去。