×××之GRE隧道协议案例配置安全
××× 虚拟专用网,全称:Virtual Private Network 是一种基于公共数据网的服务,它主要依赖ISP,在公共网络中创建虚拟专用通讯网络。
隧道技术:在×××中普遍使用了隧道技术,隧道是一种封装技术,它是利用一种网络协议来传输另外一种网络协议。即利用一种网络协议,将其它的一些协议产生的数据报文封装在本身的报文中,然后在网络中传输,它的通讯只是一个虚拟的链接。
隧道是经过隧道协议来实现,隧道协议包括:第二层隧道协议(PPTP、L2TP)和第三层隧道协议(GRE、IPsec),下面主要讲解第三层隧道协议:GRE
GRE隧道协议
GRE 通用路由封装协议,英文名称:Generic Routing Encapsulation 它其实是一种封装协议,提供了将一种协议的报文封装在另外一种协议报文中的机制,使报文可以在异种网络中传输,异种报文传输的通道称为tunnel(隧道)
GRE数据包的格式是乘客协议、封装协议与运输协议3部分组成
1.乘客协议:用户要传输的数据,这是真正用户要传输的数据,能够是IP或IPX等
2.封装协议:用于创建、保持、拆卸隧道的协议,好比GRE、IPSEC,它把乘客协议报文进行“包装”,加上一个GRE头部,而后再把封装好的原始报文和GRE头部,放在IP地方的“数据区”,由IP进行传输。
3.运输协议:主要是指乘客协议被封装协议封装以后要发送出去应用的协议,如今咱们主要使用的是IP协议。
若是使用咱们平时发信来比喻的话,乘客协议就是咱们写的信的内容(不一样的协议就等因而不一样的语言),而封装协议就是指信封,它对信件进行封装,而运输协议就是咱们用哪一种方式(协议)把信送出去。
示例:gre在中小企业中的应用
拓扑图
如今咱们的要求就是让北京总公司与上海分公司经过广域网以后,两边内网可以相互通讯,因为是实验环境,咱们使用一个三层交换机来模拟广域网,为了保证其安全性,使用两个H3C的防火墙来作GRE接入
第二阶段:配置广域网通讯
1.配置广域网
<Quidway>system
Enter system view, return to user view with Ctrl+Z.
[Quidway]vlan 10 //建立vlan10
[Quidway-vlan10]port eth0/1 //将1端口加入vlan
[Quidway-vlan10]vlan 20 //建立vlan20
[Quidway-vlan20]port eth0/2 //将端口2加入
[Quidway-vlan20]int vlan 10
[Quidway-Vlan-interface10]ip add 61.130.131.1 255.255.255.0 //配置vlan ip
[Quidway-Vlan-interface10]int vlan 20
[Quidway-Vlan-interface20]ip add 61.130.130.1 255.255.255.0 //配置vlan ip
2.北京总公司防火墙配置
<H3C>system
[H3C]int eth0/0
[H3C-Ethernet0/0]ip add 192.168.1.1 24 //配置内网网关
[H3C-Ethernet0/0]int eth0/4
[H3C-Ethernet0/4]ip add 61.130.131.2 24 //配置外网ip
[H3C]firewall zone untrust
[H3C-zone-untrust]add int eth0/4 //将eth0/4加入untrust区域
[H3C-zone-untrust]
[H3C]ip route-static 0.0.0.0 0 61.130.131.1 //配置静态路由
3.上海分公司防火墙配置
<H3C>system
System View: return to User View with Ctrl+Z.
[H3C]int eth0/0
[H3C-Ethernet0/0]ip add 192.168.2.1 24 //内网网关
[H3C-Ethernet0/0]int eth0/4
[H3C-Ethernet0/4]ip add 61.130.130.2 24 //外网IP
[H3C]firewall zone untrust
[H3C-zone-untrust]add int eth0/4 //将eth0/4加入untrust区域
[H3C]ip route-static 0.0.0.0 0 61.130.130.1 //配置静态路由
4.测试
使用北京防火墙ping上海防火墙端口ip
[H3C]ping 61.130.130.2
PING 61.130.130.2: 56 data bytes, press CTRL_C to break
Reply from 61.130.130.2: bytes=56 Sequence=1 ttl=254 time=19 ms
Reply from 61.130.130.2: bytes=56 Sequence=2 ttl=254 time=6 ms
Reply from 61.130.130.2: bytes=56 Sequence=3 ttl=254 time=5 ms
Reply from 61.130.130.2: bytes=56 Sequence=4 ttl=254 time=5 ms
Reply from 61.130.130.2: bytes=56 Sequence=5 ttl=254 time=6 ms
--- 61.130.130.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 5/8/19 ms
第二阶段:隧道配置
1. 北京总公司防火墙配置
[H3C]int Tunnel 10 //建立隧道10
[H3C-Tunnel10]tunnel-protocol gre //gre封装协议
[H3C-Tunnel10]source 61.130.131.2 //源ip(外网合法ip)
[H3C-Tunnel10]destination 61.130.130.2 //目的ip(对端合法ip)
[H3C-Tunnel10]ip add 192.168.4.1 24 //隧道ip
[H3C-Tunnel10]quit
[H3C]ip route-static 192.168.2.0 255.255.255.0 Tunnel 10 //静态路由,指出到达192.168.2.0网段的路由进入tunnel 10进行传输
[H3C]firewall zone untrust
[H3C-zone-untrust]add int Tunnel 10 //把隧道加入非安全区域
2. 上海总公司防火墙配置
[H3C]int Tunnel 20
[H3C-Tunnel20]tunnel-protocol gre
[H3C-Tunnel20]source 61.130.130.2
[H3C-Tunnel20]destination 61.130.131.2
[H3C-Tunnel20]ip add 192.168.4.2 24
[H3C-Tunnel20]quit
[H3C]ip route-static 192.168.1.0 255.255.255.0 Tunnel 20
[H3C]firewall zone untrust
[H3C-zone-untrust]add interface Tunnel 20
3.测试
使用北京总公司一个主机ping上海分公司的网关
C:\Documents and Settings\Administrator>ping 192.168.2.1
Pinging 192.168.2.1 with 32 bytes of data:
Reply from 192.168.2.1: bytes=32 time=8ms TTL=254
Reply from 192.168.2.1: bytes=32 time=5ms TTL=254
Reply from 192.168.2.1: bytes=32 time=4ms TTL=254
Reply from 192.168.2.1: bytes=32 time=4ms TTL=254
Ping statistics for 192.168.2.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 4ms, Maximum = 8ms, Average = 5ms