[VPN技术]GRE隧道的三种配置案例

实验一:配置GRE隧道,并在隧道上运行静态路由实现互通

拓扑图

![[Pasted image 20241031142000.png]]

配置要求

AR1、AR2、AR3属于VPN骨干网,它们之间运行OSPF。

AR2和AR3之间使用三层隧道协议GRE,实现PC1和PC2互联。

PC1和PC2上分别指定AR2、AR3为自己的缺省网关。

操作步骤
  1. 配置AR2
#
interface GigabitEthernet0/0/0   //配置公网出接口
 ip address 20.1.1.1 255.255.255.0 
#
interface GigabitEthernet0/0/1   //配置私网出接口
 ip address 10.1.1.2 255.255.255.0 
#
//配置Tunnel接口,Tunnel的源地址是发出报文的实际接口IP地址,目的地址是接收报文的实际接口IP地址
interface Tunnel0/0/1
 ip address 10.3.1.1 255.255.255.0 
 tunnel-protocol gre
 source 20.1.1.1
 destination 30.1.1.2
#
//配置公网路由-ospf
ospf 1 
 area 0.0.0.0 
  network 20.1.1.0 0.0.0.255 
#
//配置私网静态路由,下一条接口为Tunnel接口
ip route-static 10.2.1.0 255.255.255.0 Tunnel0/0/1
#
  1. 配置AR2
interface GigabitEthernet0/0/0
 ip address 20.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 30.1.1.1 255.255.255.0
#
ospf 1 
 area 0.0.0.0 
  network 20.1.1.0 0.0.0.255 
  network 30.1.1.0 0.0.0.255
  1. 配置AR3
#
interface GigabitEthernet0/0/0
 ip address 30.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 10.2.1.2 255.255.255.0 
#
interface Tunnel0/0/1
 ip address 10.3.1.2 255.255.255.0 
 tunnel-protocol gre
 source 30.1.1.2
 destination 20.1.1.1
#
ospf 1 
 area 0.0.0.0 
  network 30.1.1.0 0.0.0.255 
#️ 
ip route-static 10.1.1.0 255.255.255.0 tunnel0/0/1
  1. 验证:
dis ip int brief 

PC设置

  • PC1
    • IP 地址:10.1.1.1
    • 子网掩码:255.255.255.0
    • 默认网关:10.1.1.2
  • PC2
    • IP 地址:10.2.1.1
    • 子网掩码:255.255.255.0
    • 默认网关:10.2.1.2

![[Pasted image 20241031150722.png]]

实验二:GRE IPV6 to IPV4
组网需求

RouterA、RouterB、RouterC之间通过IPv4网络互连。
RouterA和RouterC分别连接到IPv6网络,且下挂IPv6主机PC1和PC2。
客户希望在RouterA和RouterC之间配置IPv6 over IPv4 GRE隧道,实现PC1和PC2间互通。

拓扑图

![[Pasted image 20241031160750.png]]

实验步骤

1.配置RA

ipv6
#
interface GigabitEthernet0/0/1
 ip address 10.1.1.1 255.255.255.0   //配置接口的IPv4地址
#
interface GigabitEthernet0/0/0
 ipv6 enable 
 ipv6 address FC01::1/64    //配置接口的IPv6地址
#
interface Tunnel0/0/1
 ipv6 enable 
 ipv6 address FC02::1/64 
 tunnel-protocol gre
 source 10.1.1.1
 destination 10.1.2.2
#
ip route-static 10.1.2.0 255.255.255.0 10.1.1.2   //配置IPv4静态路由,确保RouterA到RouterC路由可达
# 
ipv6 route-static FC03:: 64 Tunnel0/0/1   //配置IPv6静态路由,确保RouterA到PC2路由可达

  1. 配置RB
#
interface GigabitEthernet0/0/0
 ip address 10.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 10.1.2.1 255.255.255.0 
#
  1. 配置RC
ipv6
#
interface GigabitEthernet0/0/0
 ipv6 enable 
 ipv6 address FC03::1/64 
#
interface GigabitEthernet0/0/1
 ip address 10.1.2.2 255.255.255.0 
#
interface Tunnel0/0/1
 ipv6 enable 
 ipv6 address FC02::2/64 
 tunnel-protocol gre
 source 10.1.2.2
 destination 10.1.1.1
#
ip route-static 10.1.1.0 255.255.255.0 10.1.2.1  //配置IPv4静态路由,确保RouterC到RouterA路由可达
# 
ipv6 route-static FC01:: 64 Tunnel0/0/01  //配置IPv6静态路由,确保RouterC到PC1路由可达
  1. 验证:
    ![[Pasted image 20241031163454.png]]

实验三:配置GRE隧道,并在隧道上运行OSPF实现互通的示例

组网需求

AR1、AR2、AR3属于VPN骨干网,它们之间运行OSPF。
AR2和AR3之间使用三层隧道协议GRE,实现PC1和PC2互联。
PC1和PC2上分别指定AR2、AR3为自己的缺省网关。
Tunnel接口启用动态路由协议OSPF。VPN骨干网上使用OSPF进程1,用户接入部分使用OSPF进程2。
![[Pasted image 20241031164251.png]]

实验步骤

  1. AR2-RA
#
interface GigabitEthernet0/0/0
 ip address 20.1.1.1 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 10.1.1.2 255.255.255.0 
#
interface Tunnel0/0/1
 ip address 10.3.1.1 255.255.255.0 
 tunnel-protocol gre
 source 20.1.1.1
 destination 30.1.1.2
#
ospf 1 
 area 0.0.0.0 
  network 20.1.1.0 0.0.0.255 
# 
ospf 2 
 area 0.0.0.0 
  network 10.1.1.0 0.0.0.255 
  network 10.3.1.0 0.0.0.255 
# 

  1. AR1-RB
#
interface GigabitEthernet0/0/0
 ip address 20.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 30.1.1.1 255.255.255.0 
#
#
ospf 1 
 area 0.0.0.0 
  network 20.1.1.0 0.0.0.255 
  network 30.1.1.0 0.0.0.255 
#
  1. AR3-RC
#
interface GigabitEthernet0/0/0
 ip address 30.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 10.2.1.2 255.255.255.0 
#
ospf 1 
 area 0.0.0.0 
  network 30.1.1.0 0.0.0.255 
# 
ospf 2 
 area 0.0.0.0 
  network 10.2.1.0 0.0.0.255 
  network 10.3.1.0 0.0.0.255 
#
interface Tunnel0/0/1
 ip address 10.3.1.2 255.255.255.0 
 tunnel-protocol gre
 source 30.1.1.2
 destination 20.1.1.1
#
  1. 验证:
dis ip routing-table
PC>ping 10.2.1.1

Ping 10.2.1.1: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 10.2.1.1: bytes=32 seq=2 ttl=126 time=31 ms
From 10.2.1.1: bytes=32 seq=3 ttl=126 time=32 ms
From 10.2.1.1: bytes=32 seq=4 ttl=126 time=15 ms
From 10.2.1.1: bytes=32 seq=5 ttl=126 time=32 ms

--- 10.2.1.1 ping statistics ---
  5 packet(s) transmitted
  4 packet(s) received
  20.00% packet loss
  round-trip min/avg/max = 0/27/32 ms

PC>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

网工菜鸟-小陈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值