APP下载

基于Packet Tracer实现GRE VPN

2016-09-13焦慧华李湘一

关键词:PC机子网路由器

焦慧华, 李湘一, 肖 群

(琼台师范高等专科学校, 海南 海口 571127)

基于Packet Tracer实现GRE VPN

焦慧华,李湘一,肖群

(琼台师范高等专科学校, 海南海口571127)

在网络工程中,经常遇到分布在不同地理位置的总部与分部通过ISP网络连接起来,实现公司内部资源共享的情况,可以在ISP公共网络中建立一条隧道,实现总部与分部路由信息交换,达到相互通信的目的。本文利用Packet Tracer模拟器模拟公司总部与分部实现GRE VPN,达到两台电脑主机通过私有地址互相通信。

Packet Tracer;GRE VPN;通信

一、GRE工作原理

GRE(通用路由协议封装)是由Cisco和Netsmiths等公司于1994年提交给IETF(互联网的工程任务组)的,标号为RFC1701和RFC1702。用于传输三层网络协议的隧道协议。目前有多数厂商的网络设备均支持GRE隧道协议。路由器收到一个需要封装和路由的原始数据报文(Payload),这个报文首先被GRE封装成GRE报文,然后又被封装在IP协议中,由IP层负责此报文转发[1]。

原始报文的协议被称为乘客协议,GRE被称为封装协议,而负责转发的IP协议被称为传输协议[2]。

GRE优点如下:

(1)多协议的本地网络可以通过单一协议的骨干网实现传输;

(2)将一些不能连续的子网连接起来,用于组建VPN[3];

(3)扩大网络的工作范围,例如,RIP最多16跳,GRE连接隧道计1跳。

二、网络拓扑图及IP规划

如图2.1所示网络中,路由器R1与R3之间建立Tunnel,路由器R1背后的子网10.10.10.0/24与路由器R3背后的子网10.10.12.0/24通过R1与R3之间的Tunnel进行通信。这种通信通过Tunnel进行,对于R1与R3之间的外部网络是透明的和不可见的,即是一种虚拟专用网(VPN)的实现。

图2.1 网络拓扑图与IP地址分配Fig2.1 Network topology and IP address assignment

三、网络设备配置

(一)总公司R1的配置

1.R1基本配置

Router>enable

Router#config terminal

Router(config)#hostname R1

R1(config)#interface s 0/3/1

R1(config-if)#ip address 200.1.1.1 255.255.255.252

R1(config-if)#no shutdown

R1(config-if)#interface g 0/0

R1(config-if)#ip address 10.10.10.1 255.255.255.0

R1(config-if)#no shutdown

2.R1隧道及路由配置

R1(config)#interface tunnel 1

R1(config-if)#ip address 10.10.11.1 255.255.255.252

R1(config-if)#tunnel destination 200.1.1.6//配置隧道的目的地址

R1(config-if)#tunnel source s 0/3/1//配置隧道的源端口或源地址

R1(config-if)#tunnel mode gre ip

R1(config-if)#exit

R1(config)#ip route 0.0.0.0 0.0.0.0 s 0/3/1

注意此处的静态路由为R1默认网络出口

3.R1经由隧道tunnel1通向R2的路由配置

R1(config)#router rip

R1(config-router)#version 2

R1(config-router)#no auto-summary

R1(config-router)#network 10.10.10.0//在内部端口启用RIPv2

R1(config-router)#network 10.10.11.0//在GRE隧道端口启用Ripv2

R1(config-router)#exit

(二)R2的配置

Router>enable

Router#config terminal

Router(config)#hostname R2_Internet

R2_Internet(config)#interface s 0/3/1

R2_Internet(config-if)#ip address 200.1.1.2 255.255.255.252

R2_Internet(config-if)#clock rate 64000

R2_Internet(config-if)#no shutdown

R2_Internet(config-if)#interface s 0/3/0

R2_Internet(config-if)#ip address 200.1.1.5 255.255.255.252

R2_Internet(config-if)#clock rate 64000

R2_Internet(config-if)#no shutdown

R2_Internet(config-if)#exit

(三)R3的配置

1.R3基本配置

Router>enable

Router#config terminal

Router(config)#hostname R3

R3(config)#interface s 0/3/0

R3(config-if)#ip address 200.1.1.6 255.255.255.252

R3(config-if)#no shutdown

R3(config-if)#interface g 0/0

R3(config-if)#ip address 10.10.12.1 255.255.255.0

R3(config-if)#no shutdown

R3(config-if)#exit

2.R3隧道及路由配置

R3(config)#interface tunnel 1

R3(config-if)#ipaddress10.10.11.2255.255.255.252

R3(config-if)#tunnel destination 200.1.1.1//配置隧道的目的地址

R3(config-if)#tunnel source s 0/3/0//配置隧道的源端口或源地址

R3(config-if)#tunnel mode gre ip

R3#(config)#ip route 0.0.0.0 0.0.0.0 s 0/3/0

注意此处的静态路由为R3默认网络出口

3.R3经由隧道tunnel1通向R1的路由配置

R1(config)#router rip

R1(config-router)#version 2

R1(config-router)#no auto-summary

R1(config-router)#network 10.10.11.0//在内部端口启用RIPv2

R1(config-router)#network 10.10.12.0//在GRE隧道端口启用Ripv2

R1(config-router)#exit

四、Web服务器与PC机的配置

Web服务器的IP设置为:10.10.10.2,子网掩码为:255.255.255.0,网关设置为:10.10.10.1。在config选项卡位置的HTTP内的html代码进行一些明显的修改。以便在验证的时候体现出来。如图4.1,PC机的 IP设置为:10.10.12.2,子网掩码为:255.255.255.0,网关设置为:10.10.12.1。

图4.1 Web服务器的html代码设置Fig4.1 The Web server's HTML code sets

五、验证测试

在PC机10.10.12.2上的command窗口里运用tracert命令到10.10.10.2WEB服务器上。运行结果如图5.1。

图5.1 tracert命令运行结果Fig 5 .1 Run results of Tracert command

并从PC机10.10.12.2里面的浏览器访问WEB服务器10.10.10.2,其效果如图5.2

图5.2 访问web服务器效果图Fig 5 .1 Access to the web server rendering

在R3路由器的特权模式输入show ip route命令,可看到如图5.3的效果,可以看到有一项路由的信息R 10.10.10.0/24[120/1]via 10.10.11.1 00:00:02,Tunnel1,说明R3与R1已经可以通信。

图5.3 R3路由信息表

六、结论

本文利用Packet Tracer真实地模拟GRE VPN的场景,通过GRE,用户可以利用公共IP网络连接IPX网络、AppleTalk网络,还可以利用保留地址进行网络互连,或者对公网隐藏企业网的IP地址。

[1]王洪波.VPN的隧道技术分析 [J].电脑与信息技术,2002,(3).

[2]韩儒博,邬钧霆,等.虚拟专用网络及其隧道实现技术[J].微计算机信息报,2005,(21).

[3]李泞亚.VPN技术应用研究[J].南京邮电大学学报,2011,(3).

(责任编辑:魏树峰)

Implementation of GRE VPN Based on the Packet Tracer

JIAO Hui-hua,LI Xiang-yi,XIAO Qun
(Qiongtai Teachers College,Haikou 571127,Hainan)

In the network project,it is common that the headquarter and branches located in different places are connected through the ISP net,sharing the company inner resources.A tunnel can be built in the ISP public network to conduct information exchange between the headquarter and the branches.The Packet Tracer simulator is adopted to simulate the GRE VPN process between the headquarter and branches to achieve the goal of mutual communication through private addresses of the two computers.

Packet Tracer;GRE VPN

TP391.41

A

1671-802X(2016)01-0001-04

2015-09-05

焦慧华(1985-),男,江西浮梁人,硕士,工程师,研究方向:软件开发、图像处理。E-mail:282398070@qq.com.

猜你喜欢

PC机子网路由器
一种简单子网划分方法及教学案例*
买千兆路由器看接口参数
维持生命
路由器每天都要关
路由器每天都要关
子网划分问题研究及应用
基于三菱FXPLC的感应淬火机床与PC机的串行通信实现
VC.NET下实现dsPIC单片机与PC机的通信
排除OLT设备登录故障
子网划分的简易方法