English 简体中文 繁體中文 한국 사람 日本語 Deutsch русский بالعربية TÜRKÇE português คนไทย french
查看: 15|回复: 0

GRE隧道

[复制链接]
查看: 15|回复: 0

GRE隧道

[复制链接]
查看: 15|回复: 0

349

主题

0

回帖

1057

积分

金牌会员

积分
1057
fdfv232

349

主题

0

回帖

1057

积分

金牌会员

积分
1057
2025-1-16 19:07:21 | 显示全部楼层 |阅读模式
IPSEC VPN 用于两个端点之间提供安全的ip通信,但只能加密并传播单播数据,无法加密传播语音、视频、动态路由协议等组播数据流量。


通用路由封装协议GRE (Generic Routing Encapsulation)提供将一种协议报文封装在另一种协议报文中的机制,是一种隧道封装技术。




GRE可以封装组播数据,并可以和IPSEC结合使用,从而保证语音、视频等组播业务的安全。


不管什么路由,都可以封装到GRE。







IPsec VPN 能够安全传输IP报文,但是无法在隧道的两个端点之间运行RIP和OSPF等路由协议。
GRE可以将路由协议信息封装在另一种协议报文(例如IP)中进行传输。





GRE隧道可以克服IGP协议的一些局限性。如RIP路由协议是一种距离矢量路由协议,最大跳数为15.如果网络路径超过15跳,设备将无法通信,这时可以使用GRE技术,在两个网络节点之间搭建隧道,隐藏它们之间的跳数,扩大网络的工作范围。





首先通过 GRE对报文进行封装,然后由IPSEC对封装后的报文进行加密和传输。


GRE本身并不支持加密,因而通过GRE隧道传输的流量是不加密的。将IPSEC技术与GRE隧道相结合,可以建立GRE隧道对报文进行GRE封装,然后再建立IPSEC隧道对报文进行加密,以保证报文传输的完整性和私密性。










GRE在封装数据时,会添加GRE头部信息,还会添加新的传输协议头部信息。


GRE封装报文时,封装前的报文称为净荷,封装前的报文协议称为乘客协议,然后GRE会封装GRE头部,GRE成为封装协议,也叫运载协议,最后负责对封装后的报文进行转发的协议称为传输协议。











实验:



interface Tunnel interface-number命令用来创建Tunnel接口。创建Tunnel接口后,需要配置Tunnel接口Ip地址和Tunnel接口的封装协议。





tunnel-protocol 命令用来配置Tunnel接口的隧道协议。
Source source-ipaddress|interface-type interface-number命令用来指定Tunnel接口的源地址或源接口。
destination dest-ip-address命令用来指定Tunnel接口的目的IP地址。


在本端设备和远端设备上还必须存在经过Tunnel转发的路由,这样,需要进行GRE封装的报文才能正确转发。经过Tunnel接口转发的路由也可以静态路由,也可以动态路由。配置静态路由时,路由的目的地址是GRE封装前原如报文的目的地址,出接口是本端Tunnel接口。




[guangzhou]interface Tunnel 0-0 ?
                            ^
Error: Wrong parameter found at '^' position.
[guangzhou]interface Tunnel 0/0
[guangzhou]interface Tunnel 0/0/0 ?
   <cr>   Please press ENTER to execute command
[guangzhou]interface Tunnel 0/0/1
[guangzhou-Tunnel0/0/1]ip add
[guangzhou-Tunnel0/0/1]ip address 10.1.1.1 24
[guangzhou-Tunnel0/0/1]undo shutdown
Info: Interface Tunnel0/0/1 is not shutdown.
[guangzhou-Tunnel0/0/1]tun
[guangzhou-Tunnel0/0/1]tunnel-protocol ?
   gre        Generic Routing Encapsulation
   ipsec      IPSEC Encapsulation
   ipv4-ipv6   IP over IPv6 encapsulation
   ipv6-ipv4   IPv6 over IP encapsulation
   mpls       MPLS Encapsulation
   none       Null Encapsulation
[guangzhou-Tunnel0/0/1]tunnel-protocol gr
[guangzhou-Tunnel0/0/1]tunnel-protocol gre ?
   p2mp   Point to multi-point GRE mode
   <cr>   Please press ENTER to execute command
[guangzhou-Tunnel0/0/1]tunnel-protocol gre


[guangzhou-Tunnel0/0/1]source ?
   Ethernet         Ethernet interface
   GigabitEthernet   GigabitEthernet interface
   NULL             NULL interface
   Tunnel           Tunnel interface
   X.X.X.X          IP address
[guangzhou-Tunnel0/0/1]source g
[guangzhou-Tunnel0/0/1]source GigabitEthernet ?
   <0-0>   Slot number
[guangzhou-Tunnel0/0/1]source 200.1.1.1 ?
   <cr>   Please press ENTER to execute command
[guangzhou-Tunnel0/0/1]source 200.1.1.1
[guangzhou-Tunnel0/0/1]de
[guangzhou-Tunnel0/0/1]description 200.1.2.2
[guangzhou-Tunnel0/0/1]






[beijing]interface Tunnel 0/0/1
[beijing-Tunnel0/0/1]ip add
[beijing-Tunnel0/0/1]ip address 10.1.1.2
                                         ^
Error:Incomplete command found at '^' position.
[beijing-Tunnel0/0/1]ip address 10.1.1.2 24
[beijing-Tunnel0/0/1]
[beijing-Tunnel0/0/1]
[beijing-Tunnel0/0/1]so
[beijing-Tunnel0/0/1]sou
[beijing-Tunnel0/0/1]tu
[beijing-Tunnel0/0/1]tunnel-protocol gr
[beijing-Tunnel0/0/1]tunnel-protocol gre
[beijing-Tunnel0/0/1]so
[beijing-Tunnel0/0/1]source 200.1.2.2
[beijing-Tunnel0/0/1]de
[beijing-Tunnel0/0/1]description 200.1.1.1
[beijing-Tunnel0/0/1]
[beijing-Tunnel0/0/1]






[guangzhou]ip route-static 192.168.2.0 ?
   INTEGER<0-32>     Length of IP address mask
   IP_ADDR<X.X.X.X>   IP address mask
[guangzhou]ip route-static 192.168.2.0 255.255.255.0 ?
   IP_ADDR<X.X.X.X>   Gateway address
   Ethernet          Ethernet interface
   GigabitEthernet   GigabitEthernet interface
   NULL              NULL interface
   Tunnel            Tunnel interface
   vpn-instance      Destination VPN-Instance for Gateway address
[guangzhou]ip route-static 192.168.2.0 255.255.255.0 tu
[guangzhou]ip route-static 192.168.2.0 255.255.255.0 Tunnel ?
   <0-0>   Slot number
[guangzhou]ip route-static 192.168.2.0 255.255.255.0 10.1.1.1
Error: The next-hop address is invalid.
[guangzhou]ip route-static 192.168.2.0 255.255.255.0 tu
[guangzhou]ip route-static 192.168.2.0 255.255.255.0 Tunnel 0/0/1











[beijing]display   ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 0
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 1


Interface                         IP Address/Mask      Physical   Protocol   
GigabitEthernet0/0/0              200.1.2.2/24         up         up      
GigabitEthernet0/0/1              192.168.2.254/24     up         up      
NULL0                             unassigned           up         up(s)     
Tunnel0/0/1                       10.1.1.2/24          up         down     、





interface Tunnel0/0/1
description 200.1.1.1-----不是description 而是destination
ip address 10.1.1.2 255.255.255.0
tunnel-protocol gre
source 200.1.2.2
#
ip route-static 0.0.0.0 0.0.0.0 200.1.2.1
ip route-static 192.168.1.0 255.255.255.0 Tunnel0/0/1














[beijing-Tunnel0/0/1]destination 200.1.1.1
[beijing-Tunnel0/0/1]
[beijing-Tunnel0/0/1]
[beijing-Tunnel0/0/1]dis
[beijing-Tunnel0/0/1]qu
[beijing-Tunnel0/0/1]quit
[beijing]dis
[beijing]display ip in
[beijing]display ip interface br
[beijing]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 0
The number of interface that is UP in Protocol is 4
The number of interface that is DOWN in Protocol is 0


Interface                         IP Address/Mask      Physical   Protocol   
GigabitEthernet0/0/0              200.1.2.2/24         up         up      
GigabitEthernet0/0/1              192.168.2.254/24     up         up      
NULL0                             unassigned           up         up(s)     
Tunnel0/0/1                       10.1.1.2/24          up         up     










您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

349

主题

0

回帖

1057

积分

金牌会员

积分
1057

QQ|智能设备 | 粤ICP备2024353841号-1

GMT+8, 2025-3-10 15:09 , Processed in 1.746589 second(s), 29 queries .

Powered by 智能设备

©2025

|网站地图