小言_互联网的博客

GRE 隧道配置案例(静态、动态路由)

423人阅读  评论(0)

把键盘上的H&M扣下来扔了。也算是抵制了吧?

配置案例

要求

  • 配置IP地址、DHCP、路由、NAT
  • 内网可以访问公网2.2.2.2
  • 配置GRE VPN
  • PC1能直接访问PC2

拓扑

配置

基础配置

青海分部IP地址、DHCP、NAT、路由

sys
sys QH
dhcp enable

acl 2000
rule permit so 192.168.10.0 0.0.0.255

int g0/0/0
ip add 192.168.10.254 24
dhcp sel int
int g0/0/1
ip add 12.0.0.1 24
nat outbound 2000

ip route-s 0.0.0.0 0 12.0.0.2

上海总部IP地址、DHCP、NAT、路由

sys
sys SH
dhcp enable

acl 2000
rule permit so 192.168.20.0 0.0.0.255

int g0/0/1
ip add 192.168.20.254 24
dhcp sel int
int g0/0/0
ip add 23.0.0.3 24
nat outbound 2000

ip route-s 0.0.0.0 0 23.0.0.2

ISP公网

sys
sys ISP

int g0/0/0
ip add 12.0.0.2 24

int g0/0/1
ip add 23.0.0.2 24

int lo 2 
ip add  2.2.2.2 32

PC1

PC2

GRE VPN配置

青海分部

interface Tunnel0/0/1
tunnel-protocol gre
source 12.0.0.1
destination 23.0.0.3

上海总部

interface Tunnel0/0/1      #创建隧道口
tunnel-protocol gre        #指定协议
source 23.0.0.3            #指定隧道源
destination 12.0.0.1       #指定隧道目标

配置完GRE隧道发现PC1和PC2还ping 不通,因为没有路由。

配置路由

静态路由
青海分部

ip route-static 192.168.20.0 255.255.255.0 Tunnel0/0/1
ip route-static 192.168.20.0 255.255.255.0 192.168.13.3

上海总部

ip route-static 192.168.10.0 255.255.255.0 Tunnel0/0/1
ip route-static 192.168.10.0 255.255.255.0 192.168.13.1



PC1与PC2之间互通,GRE VPN建成功
动态路由
实际的生产环境中基本上用的都是动态路由ospf
青海分部

ospf  1 router-id 1.1.1.1
area 0
net 192.168.10.0 0.0.0.255
net 192.168.13.0 0.0.0.255

上海总部

ospf  1 router-id 3.3.3.3
area 0
net 192.168.20.0 0.0.0.255
net 192.168.13.0 0.0.0.255


OSPF邻居建立成功

PC1与PC2仍然能通。

GRE 隧道路由宣告注意事项:使用动态路由协议宣告接口时千万不能宣告公网接口。

测试
OSPF进程中宣告公网接口

ospf  1 router-id 1.1.1.1
area 0
net 12.0.0.1 0.0.0.0


OSPF邻居down了,一会又开始重新建邻居变成了full。这个过程反复重复。
PC1和PC2之间ping不通!!!

验证

验证隧道、路由表

青海分部


上海总部

Keeplive

GRE VPN

GRE:Generic Routing Encapsulation,通用路由封装

  • 一种三层VPN封装技术
  • 在任意一种网络协议上传送任意一种其它网络协议的封装方法
  • 解决了跨越异种网络的报文传输问题,异种报文传输的通道称为Tunnel(隧道)

GRE核心功能:建立隧道,打通私网

GRE封装:穿马甲

GRE VPN数据包转发过程





GRE 隧道口虚假状态

GRE VPN隧道口虚假状态问题:只要有到达隧道目标的路由,隧道口即可激活

解决方法:开启GRE的Keeplive,用于检测隧道对端是否可达。





把上海总部R2的 Tunnel0/0/1 删掉

OSPF邻居down了

分部路由器上的Tunnel口状态都是up(隧道口虚假状态)。

在R1上配置Keeplive,检测到了R3路由器上的Tunnel口down了。

GRE隧道恢复正常!!!


转载:https://blog.csdn.net/weixin_44309905/article/details/115466507
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场