IPSec Site-to-Site VPN with Crypto Map Configuration
Table of Contents
Jump to section:
- • What is a Policy-Based VPN?
- • What is the difference between a Policy-Based VPN and a Route-Based VPN?
- • How to configure IPSec with a crypto map?
- • IPSec crypto map with IKEv2 configuration
- • IPSec crypto map with IKEv1 and VRF configuration
- • Configuring a crypto map to encrypt GRE traffic
- • Download section
- What is a Policy-Based VPN? ‹
- What is the difference between a Policy-Based VPN and a Route-Based VPN? ‹
- How to configure IPSec with a crypto map? ‹
- IPSec crypto map with IKEv2 configuration ‹
- IPSec crypto map with IKEv1 and VRF configuration ‹
- Configuring a crypto map to encrypt GRE traffic ‹
- Download section ‹
What is a Policy-Based VPN?
A policy-based VPN uses an Access-Control List (ACL) to filter traffic intended for encryption. In other words, the ACL specifies a policy that decides whether to send traffic through the IPSec connection. In terms of IPSec VPN configuration, the ACL is called a crypto ACL. The crypto ACL is attached to a crypto map which includes further details about the negotiatied IPSec connection. A crypto map applied to a physical interface is part of a policy-based IPSec VPN configuration.
What is the difference between a Policy-Based VPN and a Route-Based VPN?
| Policy-Based VPN | Route-Based VPN |
|---|---|
| No GRE tunnel, crypto map is configured on physical interface | Uses GRE tunnel, IPSec tunnel protection is configured on tunnel interface |
| Cannot use NAT for source and destination IPsec encrypted traffic | Can use NAT, as long as GRE tunnel endpoints can reach each other |
| Does not support dynamic routing protocols, no support for multicast | Does support dynamic routing protocols, multicast traffic is supported |
| Uses a crypto ACL to define traffic for encryption | Uses an IP route (static or dynamic) to send traffic to GRE tunnel interface |
How to configure IPSec with a crypto map?
In the following example topology two sites are connected over a simulated public network. The public network is unsecured and therefore an IPSec Site-to-Site VPN is configured between R1 and R2. The IPSec VPN encrypts traffic between Site 1 and Site 2. The configuration is applied with a crypto map and applied to the physical Gi0/1 interface on both routers.
Notice that IPSec crypto map is a Policy Based VPN and has a crypto ACL configured on both routers to define interesting traffic that should be sent encrypted over the public network. The IPSec Security Association (SA) does not establish until traffic is initiated between the two sites. IKEv1 is used to establish the SA.
Configuration:
R1
R1#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to public network ** ip address 10.1.0.1 255.255.255.252 duplex auto speed auto media-type rj45 crypto map CRYPTO-MAP R1#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host1 ** ip address 192.168.1.2 255.255.255.0 duplex auto speed auto media-type rj45 R1#show run | sec ^crypto crypto isakmp policy 2 authentication pre-share crypto isakmp key p4ssw0rd.123 address 10.2.0.1 crypto ipsec transform-set CRYPTO-TRANSFORM esp-aes mode tunnel crypto map CRYPTO-MAP 10 ipsec-isakmp set peer 10.2.0.1 set transform-set CRYPTO-TRANSFORM match address ACL-CRYPTO R1#show run | sec ^ip access ip access-list extended ACL-CRYPTO permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255 R1#show run | sec ^ip route ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/1 10.1.0.2
R2
R2#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to public network ** ip address 10.2.0.1 255.255.255.252 duplex auto speed auto media-type rj45 crypto map CRYPTO-MAP R2#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host2 ** ip address 192.168.2.2 255.255.255.0 duplex auto speed auto media-type rj45 R2#show run | sec ^crypto crypto isakmp policy 2 authentication pre-share crypto isakmp key p4ssw0rd.123 address 10.1.0.1 crypto ipsec transform-set CRYPTO-TRANSFORM esp-aes mode tunnel crypto map CRYPTO-MAP 10 ipsec-isakmp set peer 10.1.0.1 set transform-set CRYPTO-TRANSFORM match address ACL-CRYPTO R2#show run | sec ^ip access ip access-list extended ACL-CRYPTO permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255 R2#show run | sec ^ip route ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/1 10.2.0.2
R1#show crypto session Crypto session current status Interface: GigabitEthernet0/1 Session status: UP-ACTIVE Peer: 10.2.0.1 port 500 Session ID: 0 IKEv1 SA: local 10.1.0.1/500 remote 10.2.0.1/500 Active « IKEv1 is being used IPSEC FLOW: permit ip 192.168.1.0/255.255.255.0 192.168.2.0/255.255.255.0 Active SAs: 2, origin: crypto map « Crypto map is being used R1#show crypto session brief Status: A- Active, U - Up, D - Down, I - Idle, S - Standby, N - Negotiating K - No IKE ivrf = (none) Peer I/F Username Group/Phase1_id Uptime Status 10.2.0.1 Gi0/1 10.2.0.1 00:15:55 UA « Security Association Up and Active Host1#ping 192.168.2.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 46/47/49 ms « Host1 can reach Host2 throug the IPSec VPN Host1#trace 192.168.2.1 probe 1 Type escape sequence to abort. Tracing the route to 192.168.2.1 VRF info: (vrf in name/id, vrf out name/id) 1 192.168.1.2 2 msec 2 * 3 192.168.2.1 47 msec
IPSec crypto map with IKEv2 configuration
In the following scenario Site 1 and Site 2 are connected with a crypto map IPSec VPN using IKEv2. This configuration provides improved security over the IKEv1 key exchange and SA establishment. The crypto map configuration is applied on the physical interface of both routers and uses a crypto ACL to filter traffic that will be sent encrypted through the IPSec connection.
Configuration:
R1
R1#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to public network ** ip address 10.1.0.1 255.255.255.252 duplex auto speed auto media-type rj45 crypto map CRYPTO-MAP R1#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host1 ** ip address 192.168.1.2 255.255.255.0 duplex auto speed auto media-type rj45 R1#show run | sec ^crypto crypto ikev2 proposal CRYPTO-PROPOSAL encryption aes-cbc-256 integrity sha256 group 14 crypto ikev2 policy CRYPTO-POLICY match address local 10.1.0.1 proposal CRYPTO-PROPOSAL crypto ikev2 keyring CRYPTO-KEYRING peer CRYPTO-PEER address 0.0.0.0 0.0.0.0 pre-shared-key p4ssw0rd.123 ! crypto ikev2 profile IKEv2-PROFILE match identity remote address 10.2.0.1 255.255.255.255 authentication remote pre-share authentication local pre-share keyring local CRYPTO-KEYRING crypto ipsec transform-set CRYPTO-TRANSFORM esp-aes mode tunnel crypto map CRYPTO-MAP 10 ipsec-isakmp set peer 10.2.0.1 set transform-set CRYPTO-TRANSFORM set ikev2-profile IKEv2-PROFILE match address ACL-CRYPTO R1#show run | sec ^ip access ip access-list extended ACL-CRYPTO permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255 R1#show run | sec ^ip route ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/1 10.1.0.2
R2
R2#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to public network ** ip address 10.2.0.1 255.255.255.252 duplex auto speed auto media-type rj45 crypto map CRYPTO-MAP R2#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host2 ** ip address 192.168.2.2 255.255.255.0 duplex auto speed auto media-type rj45 R2#show run | sec ^crypto crypto ikev2 proposal CRYPTO-PROPOSAL encryption aes-cbc-256 integrity sha256 group 14 crypto ikev2 policy CRYPTO-POLICY match address local 10.2.0.1 proposal CRYPTO-PROPOSAL crypto ikev2 keyring CRYPTO-KEYRING peer CRYPTO-PEER address 0.0.0.0 0.0.0.0 pre-shared-key p4ssw0rd.123 ! crypto ikev2 profile IKEv2-PROFILE match identity remote address 10.1.0.1 255.255.255.255 authentication remote pre-share authentication local pre-share keyring local CRYPTO-KEYRING crypto ipsec transform-set CRYPTO-TRANSFORM esp-aes mode tunnel crypto map CRYPTO-MAP 10 ipsec-isakmp set peer 10.1.0.1 set transform-set CRYPTO-TRANSFORM set ikev2-profile IKEv2-PROFILE match address ACL-CRYPTO R2#show run | sec ^ip access ip access-list extended ACL-CRYPTO permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255 R2#show run | sec ^ip route ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/1 10.2.0.2
R1#show crypto session Crypto session current status Interface: GigabitEthernet0/1 Profile: IKEv2-PROFILE Session status: UP-ACTIVE Peer: 10.2.0.1 port 500 Session ID: 3 IKEv2 SA: local 10.1.0.1/500 remote 10.2.0.1/500 Active « IKEv2 is used IPSEC FLOW: permit ip 192.168.1.0/255.255.255.0 192.168.2.0/255.255.255.0 Active SAs: 2, origin: crypto map R1#show crypto session brief Status: A- Active, U - Up, D - Down, I - Idle, S - Standby, N - Negotiating K - No IKE ivrf = (none) Peer I/F Username Group/Phase1_id Uptime Status 10.2.0.1 Gi0/1 10.2.0.1 00:10:33 UA
IPSec crypto map with IKEv1 and VRF configuration
In this example scenario, two sites are connected through a public network using a crypto map IPSec VPN. Site 1 is configured in a VRF named VRF-ONE, and Site 2 uses VRF-TWO. Thus, R1 and R2 use different VRFs. Routes are exchanged between the two VRFs using BGP VPNv4 and route-target import/export rules configured in the public network. This allows R1 and R2 to communicate.
Notice that the crypto map configuration is applied on the interfaces using the appropriate VRF on R1 and R2. A crypto keyring ensures that the pre-shared key is communicated within the correct VRF. Also, an ISAKMP profile ensures that the IPSec peer's identity resides in a VRF. As a result, Host1 and Host2 can securely communicate over the public network using IPSec encryption in a VRF.
Configuration:
R1
R1#show run | sec ^vrf vrf definition VRF-ONE rd 1:1 ! address-family ipv4 exit-address-family R1#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to public network ** vrf forwarding VRF-ONE ip address 10.1.0.1 255.255.255.252 duplex auto speed auto media-type rj45 crypto map CRYPTO-MAP R1#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host1 ** vrf forwarding VRF-ONE ip address 192.168.1.2 255.255.255.0 duplex auto speed auto media-type rj45 R1#show run | sec ^crypto crypto keyring CRYPTO-KEYRING vrf VRF-ONE pre-shared-key address 10.2.0.1 key p4ssw0rd.123 crypto isakmp profile CRYPTO-PROFILE keyring CRYPTO-KEYRING match identity address 10.2.0.1 255.255.255.255 VRF-ONE crypto ipsec transform-set CRYPTO-TRANSFORM esp-aes mode tunnel crypto map CRYPTO-MAP 10 ipsec-isakmp set peer 10.2.0.1 set transform-set CRYPTO-TRANSFORM match address ACL-CRYPTO R1#show run | sec ^ip route ip route vrf VRF-ONE 0.0.0.0 0.0.0.0 GigabitEthernet0/1 10.1.0.2
R2
R2#show run | sec ^vrf vrf definition VRF-TWO rd 2:2 ! address-family ipv4 exit-address-family R2#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to public network ** vrf forwarding VRF-TWO ip address 10.2.0.1 255.255.255.252 duplex auto speed auto media-type rj45 crypto map CRYPTO-MAP R2#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host2 ** vrf forwarding VRF-TWO ip address 192.168.2.2 255.255.255.0 duplex auto speed auto media-type rj45 R2#show run | sec ^crypto crypto keyring CRYPTO-KEYRING vrf VRF-TWO pre-shared-key address 10.1.0.1 key p4ssw0rd.123 crypto isakmp profile CRYPTO-PROFILE keyring CRYPTO-KEYRING match identity address 10.1.0.1 255.255.255.255 VRF-TWO crypto ipsec transform-set CRYPTO-TRANSFORM esp-aes mode tunnel crypto map CRYPTO-MAP 10 ipsec-isakmp set peer 10.1.0.1 set transform-set CRYPTO-TRANSFORM match address ACL-CRYPTO R2#show run | sec ^ip route ip route vrf VRF-TWO 0.0.0.0 0.0.0.0 GigabitEthernet0/1 10.2.0.2
PE1 (public network)
PE1#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to R1 VRF-ONE ** vrf forwarding VRF-ONE ip address 10.1.0.2 255.255.255.252 duplex auto speed auto media-type rj45 PE1#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to PE2 - public network edge ** ip address 10.0.0.1 255.255.255.0 duplex auto speed auto media-type rj45 mpls ip PE1#show run | sec ^vrf vrf definition VRF-ONE rd 1:1 route-target export 65001:1 route-target import 65001:2 ! address-family ipv4 exit-address-family PE1#show run | sec ^router router bgp 65001 bgp router-id 1.1.1.1 bgp log-neighbor-changes neighbor 10.0.0.2 remote-as 65001 neighbor 10.0.0.2 next-hop-self ! address-family vpnv4 neighbor 10.0.0.2 activate neighbor 10.0.0.2 send-community extended exit-address-family ! address-family ipv4 vrf VRF-ONE redistribute connected exit-address-family PE1#show run all | sec ^mpls ip__ mpls ip
PE2 (public network)
PE2#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to R2 VRF-TWO ** vrf forwarding VRF-TWO ip address 10.2.0.2 255.255.255.252 duplex auto speed auto media-type rj45 PE2#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to PE1 - public network edge ** ip address 10.0.0.2 255.255.255.0 duplex auto speed auto media-type rj45 mpls ip PE2#show run | sec ^vrf vrf definition VRF-TWO rd 2:2 ! address-family ipv4 route-target export 65001:2 route-target import 65001:1 exit-address-family PE2#show run | sec ^router router bgp 65001 bgp router-id 2.2.2.2 bgp log-neighbor-changes neighbor 10.0.0.1 remote-as 65001 neighbor 10.0.0.1 next-hop-self ! address-family vpnv4 neighbor 10.0.0.1 activate neighbor 10.0.0.1 send-community extended exit-address-family ! address-family ipv4 vrf VRF-TWO redistribute connected exit-address-family PE2#show run all | sec ^mpls ip__ mpls ip
Host1
Host1#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to R1 ** ip address 192.168.1.1 255.255.255.0 duplex auto speed auto media-type rj45 Host1#show run | sec ^ip route ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/0 192.168.1.2
Host2
Host2#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to R2 ** ip address 192.168.2.1 255.255.255.0 duplex auto speed auto media-type rj45 Host2#show run | sec ^ip route ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/0 192.168.2.2
R1#show crypto session Crypto session current status Interface: GigabitEthernet0/1 Profile: CRYPTO-PROFILE Session status: UP-ACTIVE Peer: 10.2.0.1 port 500 Session ID: 0 IKEv1 SA: local 10.1.0.1/500 remote 10.2.0.1/500 Active « IKEv1 is used IPSEC FLOW: permit ip 192.168.1.0/255.255.255.0 192.168.2.0/255.255.255.0 Active SAs: 2, origin: crypto map R1#show crypto session detail Crypto session current status Code: C - IKE Configuration mode, D - Dead Peer Detection K - Keepalives, N - NAT-traversal, T - cTCP encapsulation X - IKE Extended Authentication, F - IKE Fragmentation R - IKE Auto Reconnect, U - IKE Dynamic Route Update S - SIP VPN Interface: GigabitEthernet0/1 Profile: CRYPTO-PROFILE Uptime: 00:24:13 Session status: UP-ACTIVE Peer: 10.2.0.1 port 500 fvrf: VRF-ONE ivrf: VRF-ONE « VRF is being used with crypto map Phase1_id: 10.2.0.1 Desc: (none) Session ID: 0 IKEv1 SA: local 10.1.0.1/500 remote 10.2.0.1/500 Active Capabilities:(none) connid:1004 lifetime:23:35:46 IPSEC FLOW: permit ip 192.168.1.0/255.255.255.0 192.168.2.0/255.255.255.0 Active SAs: 2, origin: crypto map Inbound: #pkts dec'ed 16 drop 0 life (KB/Sec) 4251658/2146 Outbound: #pkts enc'ed 26 drop 0 life (KB/Sec) 4251657/2146 R1#show crypto session brief Status: A- Active, U - Up, D - Down, I - Idle, S - Standby, N - Negotiating K - No IKE ivrf = VRF-ONE Peer I/F Username Group/Phase1_id Uptime Status 10.2.0.1 Gi0/1 10.2.0.1 00:24:39 UA « IPSec connection Up and Active Host1#ping 192.168.2.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 46/46/47 ms « Host1 can reach Host2 over IPsec
Configuring a crypto map to encrypt GRE traffic
In the following scenario a crypto map is configured on the physical interface Gi0/1 of R1 and R2. The crypto ACL selects all GRE tunnel protocol traffic to be encrypted. This means that the GRE tunnel configured between R1 and R2 is encrypted by the crypto map. The advantage of a GRE tunnel is that multicast traffic is forwarded, thus a dynamic routing protocol such as OSPF can be configured between the two sites.
Configuration:
R1
R1#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to public network ** ip address 10.1.0.1 255.255.255.252 duplex auto speed auto media-type rj45 crypto map CRYPTO-MAP R1#show run int Tu10 | sec int interface Tunnel10 description ** Site-to-Site GRE Tunnel ** ip address 172.16.0.1 255.255.255.252 tunnel source GigabitEthernet0/1 tunnel destination 10.2.0.1 R1#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host1 ** ip address 192.168.1.2 255.255.255.0 duplex auto speed auto media-type rj45 R1#show run | sec ^crypto crypto isakmp policy 2 authentication pre-share crypto isakmp key p4ssw0rd.123 address 10.2.0.1 crypto ipsec transform-set CRYPTO-TRANSFORM esp-aes mode tunnel crypto map CRYPTO-MAP 10 ipsec-isakmp set peer 10.2.0.1 set transform-set CRYPTO-TRANSFORM match address ACL-CRYPTO R1#show run | sec ^ip access-list ip access-list extended ACL-CRYPTO permit gre any any R1#show run | sec ^ip route ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/1 10.1.0.2
R2
R2#show run int Gi0/1 | sec int interface GigabitEthernet0/1 description ** to public network ** ip address 10.2.0.1 255.255.255.252 duplex auto speed auto media-type rj45 crypto map CRYPTO-MAP R2#show run int Tu10 | sec int interface Tunnel10 description ** Site-to-Site GRE Tunnel ** ip address 172.16.0.2 255.255.255.252 tunnel source GigabitEthernet0/1 tunnel destination 10.1.0.1 R2#show run int Gi0/0 | sec int interface GigabitEthernet0/0 description ** to Host2 ** ip address 192.168.2.2 255.255.255.0 duplex auto speed auto media-type rj45 R2#show run | sec ^crypto crypto isakmp policy 2 authentication pre-share crypto isakmp key p4ssw0rd.123 address 10.1.0.1 crypto ipsec transform-set CRYPTO-TRANSFORM esp-aes mode tunnel crypto map CRYPTO-MAP 10 ipsec-isakmp set peer 10.1.0.1 set transform-set CRYPTO-TRANSFORM match address ACL-CRYPTO R2#show run | sec ^ip access-list ip access-list extended ACL-CRYPTO permit gre any any R2#show run | sec ^ip route ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/1 10.2.0.2
R1#show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 0 FULL/ - 00:00:38 172.16.0.2 Tunnel10 « OSPF neighborship established on Tunnel interface R1#show ip access-list Extended IP access list ACL-CRYPTO 10 permit gre any any (141 matches) « ACL filters GRE traffic for encryption R1#show crypto session detail Crypto session current status Code: C - IKE Configuration mode, D - Dead Peer Detection K - Keepalives, N - NAT-traversal, T - cTCP encapsulation X - IKE Extended Authentication, F - IKE Fragmentation R - IKE Auto Reconnect, U - IKE Dynamic Route Update S - SIP VPN Interface: GigabitEthernet0/1 Uptime: 00:18:32 Session status: UP-ACTIVE Peer: 10.2.0.1 port 500 fvrf: (none) ivrf: (none) Phase1_id: 10.2.0.1 Desc: (none) Session ID: 0 IKEv1 SA: local 10.1.0.1/500 remote 10.2.0.1/500 Active Capabilities:(none) connid:1001 lifetime:23:41:26 IPSEC FLOW: permit 47 0.0.0.0/0.0.0.0 0.0.0.0/0.0.0.0 Active SAs: 2, origin: crypto map Inbound: #pkts dec'ed 138 drop 0 life (KB/Sec) 4250217/2487 « Packets are being decrypted and encrypted Outbound: #pkts enc'ed 140 drop 0 life (KB/Sec) 4250217/2487 R1#show crypto session brief Status: A- Active, U - Up, D - Down, I - Idle, S - Standby, N - Negotiating K - No IKE ivrf = (none) Peer I/F Username Group/Phase1_id Uptime Status 10.2.0.1 Gi0/1 10.2.0.1 00:18:49 UA « The IPSec connection is Up and Active Host1#ping 192.168.2.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 47/47/48 ms « Host1 can ping Host2 Host1#trace 192.168.2.1 probe 1 Type escape sequence to abort. Tracing the route to 192.168.2.1 VRF info: (vrf in name/id, vrf out name/id) 1 192.168.1.2 2 msec 2 172.16.0.2 47 msec « The GRE Tunnel is used to reach Host2 from Host1 3 192.168.2.1 47 msec