---
title: "gre over ipsec配置"
author: "Cash"
date: "2011-02-13T22:17:55Z"
tags: ["Access"]
categories: ["互联网"]
slug: "gre-over-ipsec"
draft: false
lastmod: "2011-02-13T22:17:55Z"
id: 905434
url: "https://cash.iteye.com/blog/905434"
---

![](http://dl.iteye.com/upload/attachment/415771/77172954-8fb7-323f-b3ad-f84c057adb2e.gif)  
使用gre封装路由更新信息，然后被ipsec封装后发送，使路由更新信息安全穿越广域网络！

 

注：GRE通道ip地址不在ipsec配置中被使用！

 

以下为配置文件：

 -------

!  
!  
version 12.4  
service timestamps debug datetime msec  
service timestamps log datetime msec  
no service password-encryption  
!  
hostname R1  
!  
boot-start-marker  
boot-end-marker  
!  
!  
no aaa new-model  
!  
resource policy  
!  
memory-size iomem 5  
ip cef  
!  
!  
!  
!  
no ip domain lookup  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
crypto isakmp policy 10  
 encr 3des  
 hash md5  
 authentication pre-share  
crypto isakmp key abc address 7.7.7.2  
!  
!  
crypto ipsec transform-set set1 esp-des  
!  
crypto map map1 10 ipsec-isakmp  
 set peer 7.7.7.2  
 set transform-set set1  
 match address 100  
!  
!  
!  
!  
!  
interface Tunnel0  
 ip address 172.16.1.1 255.255.255.252  
 tunnel source Serial1/0  
 tunnel destination 7.7.7.2  
!  
interface Loopback0  
 ip address 192.168.1.1 255.255.255.0  
!  
interface FastEthernet0/0  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface FastEthernet0/1  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface Serial1/0  
 ip address 1.1.1.1 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
 crypto map map1  
!  
interface Serial1/1  
 ip address 2.2.2.1 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/2  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/3  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
router ospf 100  
 log-adjacency-changes  
 network 172.16.0.0 0.0.255.255 area 0  
 network 192.168.1.0 0.0.0.255 area 0  
!  
router rip  
 network 1.0.0.0  
 network 2.0.0.0  
 no auto-summary  
!  
!  
!  
no ip http server  
no ip http secure-server  
!  
access-list 100 permit ip 192.168.1.0 0.0.0.255 192.168.7.0 0.0.0.255  
access-list 100 permit ip host 1.1.1.1 host 7.7.7.2  
!  
!  
!  
!  
!  
!  
control-plane  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
line con 0  
 exec-timeout 0 0  
 logging synchronous  
line aux 0  
line vty 0 4  
 login  
!  
!  
webvpn context Default\_context  
 ssl authenticate verify all  
 !  
 no inservice  
!  
!  
end

\------

!  
!  
version 12.4  
service timestamps debug datetime msec  
service timestamps log datetime msec  
no service password-encryption  
!  
hostname R2  
!  
boot-start-marker  
boot-end-marker  
!  
!  
no aaa new-model  
!  
resource policy  
!  
memory-size iomem 5  
ip cef  
!  
!  
!  
!  
no ip domain lookup  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
interface Loopback0  
 ip address 192.168.2.1 255.255.255.0  
!  
interface FastEthernet0/0  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface FastEthernet0/1  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface Serial1/0  
 ip address 1.1.1.2 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/1  
 ip address 3.3.3.1 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/2  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/3  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
router rip  
 network 1.0.0.0  
 network 3.0.0.0  
 no auto-summary  
!  
!  
!  
no ip http server  
no ip http secure-server  
!  
!  
!  
!  
!  
!  
!  
control-plane  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
line con 0  
 exec-timeout 0 0  
 logging synchronous  
line aux 0  
line vty 0 4  
 login  
!  
!  
webvpn context Default\_context  
 ssl authenticate verify all  
 !  
 no inservice  
!  
!  
end

\-------

!

!  
!  
version 12.4  
service timestamps debug datetime msec  
service timestamps log datetime msec  
no service password-encryption  
!  
hostname R3  
!  
boot-start-marker  
boot-end-marker  
!  
!  
no aaa new-model  
!  
resource policy  
!  
memory-size iomem 5  
ip cef  
!  
!  
!  
!  
no ip domain lookup  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
interface Loopback0  
 ip address 192.168.3.1 255.255.255.0  
!  
interface FastEthernet0/0  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface FastEthernet0/1  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface Serial1/0  
 ip address 2.2.2.2 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/1  
 ip address 4.4.4.1 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/2  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/3  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
!  
!  
no ip http server  
no ip http secure-server  
!  
!  
!  
!  
!  
!  
!  
control-plane  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
line con 0  
 exec-timeout 0 0  
 logging synchronous  
line aux 0  
line vty 0 4  
!  
!  
webvpn context Default\_context  
 ssl authenticate verify all  
 !  
 no inservice  
!  
!  
end

\-------

!  
!  
version 12.4  
service timestamps debug datetime msec  
service timestamps log datetime msec  
no service password-encryption  
!  
hostname R4  
!  
boot-start-marker  
boot-end-marker  
!  
!  
no aaa new-model  
!  
resource policy  
!  
memory-size iomem 5  
ip cef  
!  
!  
!  
!  
no ip domain lookup  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
interface Loopback0  
 ip address 192.168.4.1 255.255.255.0  
!  
interface FastEthernet0/0  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface FastEthernet0/1  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface Serial1/0  
 ip address 3.3.3.2 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/1  
 ip address 4.4.4.2 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/2  
 ip address 5.5.5.1 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/3  
 ip address 6.6.6.1 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
router rip  
 network 3.0.0.0  
 network 4.0.0.0  
 network 5.0.0.0  
 network 6.0.0.0  
 no auto-summary  
!  
!  
!  
no ip http server  
no ip http secure-server  
!  
!  
!  
!  
!  
!  
!  
control-plane  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
line con 0  
 exec-timeout 0 0  
 logging synchronous  
line aux 0  
line vty 0 4  
 login  
!  
!  
webvpn context Default\_context  
 ssl authenticate verify all  
 !  
 no inservice  
!  
!  
end

\-------

!  
!  
version 12.4  
service timestamps debug datetime msec  
service timestamps log datetime msec  
no service password-encryption  
!  
hostname R5  
!  
boot-start-marker  
boot-end-marker  
!  
!  
no aaa new-model  
!  
resource policy  
!  
memory-size iomem 5  
ip cef  
!  
!  
!  
!  
no ip domain lookup  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
interface Loopback0  
 ip address 192.168.5.1 255.255.255.0  
!  
interface FastEthernet0/0  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface FastEthernet0/1  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface Serial1/0  
 ip address 5.5.5.2 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/1  
 ip address 7.7.7.1 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/2  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/3  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
router rip  
 network 5.0.0.0  
 network 7.0.0.0  
 no auto-summary  
!  
!  
!  
no ip http server  
no ip http secure-server  
!  
!  
!  
!  
!  
!  
!  
control-plane  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
line con 0  
 exec-timeout 0 0  
 logging synchronous  
line aux 0  
line vty 0 4  
 login  
!  
!  
webvpn context Default\_context  
 ssl authenticate verify all  
 !  
 no inservice  
!  
!  
end

\-------

!

!  
!  
version 12.4  
service timestamps debug datetime msec  
service timestamps log datetime msec  
no service password-encryption  
!  
hostname R6  
!  
boot-start-marker  
boot-end-marker  
!  
!  
no aaa new-model  
!  
resource policy  
!  
memory-size iomem 5  
ip cef  
!  
!  
!  
!  
no ip domain lookup  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
interface Loopback0  
 ip address 192.168.6.1 255.255.255.0  
!  
interface FastEthernet0/0  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface FastEthernet0/1  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface Serial1/0  
 ip address 6.6.6.2 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/1  
 ip address 8.8.8.1 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/2  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/3  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
!  
!  
no ip http server  
no ip http secure-server  
!  
!  
!  
!  
!  
!  
!  
control-plane  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
line con 0  
 exec-timeout 0 0  
 logging synchronous  
line aux 0  
line vty 0 4  
!  
!  
webvpn context Default\_context  
 ssl authenticate verify all  
 !  
 no inservice  
!  
!  
end

\-------

!  
!  
version 12.4  
service timestamps debug datetime msec  
service timestamps log datetime msec  
no service password-encryption  
!  
hostname R7  
!  
boot-start-marker  
boot-end-marker  
!  
!  
no aaa new-model  
!  
resource policy  
!  
memory-size iomem 5  
ip cef  
!  
!  
!  
!  
no ip domain lookup  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
crypto isakmp policy 10  
 encr 3des  
 hash md5  
 authentication pre-share  
crypto isakmp key abc address 1.1.1.1  
!  
!  
crypto ipsec transform-set set1 esp-des  
!  
crypto map map1 10 ipsec-isakmp  
 set peer 1.1.1.1  
 set transform-set set1  
 match address 100  
!  
!  
!  
!  
!  
interface Tunnel0  
 ip address 172.16.1.2 255.255.255.252  
 tunnel source Serial1/0  
 tunnel destination 1.1.1.1  
!  
interface Loopback0  
 ip address 192.168.7.1 255.255.255.0  
!  
interface FastEthernet0/0  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface FastEthernet0/1  
 no ip address  
 shutdown  
 duplex auto  
 speed auto  
!  
interface Serial1/0  
 ip address 7.7.7.2 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
 crypto map map1  
!  
interface Serial1/1  
 ip address 8.8.8.2 255.255.255.252  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/2  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
interface Serial1/3  
 no ip address  
 shutdown  
 serial restart-delay 0  
 no dce-terminal-timing-enable  
!  
router ospf 100  
 log-adjacency-changes  
 network 172.16.0.0 0.0.255.255 area 0  
 network 192.168.7.0 0.0.0.255 area 0  
!  
router rip  
 network 7.0.0.0  
 network 8.0.0.0  
 no auto-summary  
!  
!  
!  
no ip http server  
no ip http secure-server  
!  
access-list 100 permit ip 192.168.7.0 0.0.0.255 192.168.1.0 0.0.0.255  
access-list 100 permit ip host 7.7.7.2 host 1.1.1.1  
!  
!  
!  
!  
!  
!  
control-plane  
!  
!  
!  
!  
!  
!  
!  
!  
!  
!  
line con 0  
 exec-timeout 0 0  
 logging synchronous  
line aux 0  
line vty 0 4  
 login  
!  
!  
webvpn context Default\_context  
 ssl authenticate verify all  
 !  
 no inservice  
!  
!  
end

\------