Cisco设备上配置GRE+IPSec

一、GREVPN(Generic Routing Encapsulation)通用路由封装,配合IPSec(加密数据)一起使用

GRE配置命令

interface tunnel 0  //创建tunnel(虚拟)接口(GRE隧道)

tunnel source 11.1.1.2   //指定本地的公网IP地址

tunnel destination 21.1.1.3   //指定对端的公网IP地址

ip address 192.168.1.2 255.255.255.0 //为本虚拟接口配置IP(内网)地址

 

二、配置案例

1、R1配置:

R1(config)# interface FastEthernet0/0

R1(config-if)# ip address 11.1.1.1 255.255.255.0

R1(config-if)# no shutdown

R1(config)# interface FastEthernet0/1

R1(config-if)# ip address 21.1.1.1 255.255.255.0

R1(config-if)# no shutdown

R1(config)# interface FastEthernet1/0

R1(config-if)# ip address 25.1.1.1 255.255.255.0

R1(config-if)# no shutdown

2、R2配置:

R2(config)# crypto isakmp policy 10

R2(config-isakmp)# encr aes

R2(config-isakmp)# hash md5

R2(config-isakmp)# authentication pre-share

R2(config-isakmp)# group 2

R2(config-isakmp)# lifetime 3600

R2(config-isakmp)# crypto isakmp key 6 CISCO20 address 0.0.0.0 0.0.0.0

R2(config)# crypto ipsec transform-set CISCO esp-aes esp-md5-hmac

R2(cfg-crypto-trans)# mode transport

R2(cfg-crypto-trans)# crypto ipsec profile MYPROFILE

R2(ipsec-profile)# set transform-set CISCO

 

R2(config)# interface Loopback0

R2(config-if)# ip address 2.2.2.2 255.255.255.255

R2(config-if)# ip ospf 1 area 0

R2(config)# interface FastEthernet0/0

R2(config-if)# ip address 11.1.1.2 255.255.255.0

R2(config-if)# no shutdown

R2(config)# ip route 0.0.0.0 0.0.0.0 11.1.1.1

R2(config)# interface tunnel 0

R2(config-if)# tunnel source 11.1.1.2

R2(config-if)# tunnel destination 21.1.1.3

R2(config-if)# ip address 192.168.1.2 255.255.255.0

R2(config-if)# tunnel protection ipsec profile MYPROFILE

R2(config-if)# ip ospf 1 area 0

 

3、R3配置:

R3(config)# crypto isakmp policy 10

R3(config-isakmp)# encr aes

R3(config-isakmp)# hash md5

R3(config-isakmp)# authentication pre-share

R3(config-isakmp)# group 2

R3(config-isakmp)# lifetime 3600

R3(config-isakmp)# crypto isakmp key 6 CISCO20 address 0.0.0.0 0.0.0.0

R3(config)# crypto ipsec transform-set CISCO esp-aes esp-md5-hmac

R3(cfg-crypto-trans)# mode transport

R3(cfg-crypto-trans)# crypto ipsec profile MYPROFILE

R3(ipsec-profile)# set transform-set CISCO

 

R3(config)# interface Loopback0

R3(config-if)# ip address 3.3.3.3 255.255.255.255

R3(config-if)# ip ospf 1 area 0

R3(config)# interface FastEthernet0/1

R3(config-if)# ip address 21.1.1.3 255.255.255.0

R3(config-if)# no shutdown

R3(config)# ip route 0.0.0.0 0.0.0.0 21.1.1.1

R3(config)# interface Tunnel0

R3(config-if)# ip address 192.168.1.3 255.255.255.0

R3(config-if)# tunnel source 21.1.1.3

R3(config-if)# tunnel destination 11.1.1.2

R3(config-if)# tunnel protection ipsec profile MYPROFILE

R3(config-if)# ip ospf 1 area 0

4、R4配置:

crypto isakmp policy 10

 encr aes

 hash md5

 authentication pre-share

 group 2

 lifetime 3600

crypto isakmp key 6 CISCO20 address 0.0.0.0 0.0.0.0

crypto ipsec transform-set CISCO esp-aes esp-md5-hmac

 mode transport

crypto ipsec profile MYPROFILE

 set transform-set CISCO

 

interface Loopback0

 ip address 4.4.4.4 255.255.255.255

 ip ospf 1 area 0

interface FastEthernet1/0

 ip address 25.1.1.4 255.255.255.0

no shutdown

interface Tunnel0

 ip address 192.168.2.4 255.255.255.0

 ip ospf 1 area 0

 tunnel source 25.1.1.4

 tunnel destination 11.1.1.2

 tunnel protection ipsec profile MYPROFILE

route 0.0.0.0 0.0.0.0 25.1.1.1

 

三、验证

R2# ping 192.168.1.3

R2# traceroute 3.3.3.3 source loopback 0

抓包查看,数据已成功被加密

 

  • 1
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值