IOS Router to Pass a LAN−to−LAN IPSec Tunnel via PAT Configuration Example


Introduction

This document provides a sample configuration for Port Address Translation (PAT) to allow a LAN-to-LAN IPSec tunnel to be established. It applies to scenarios that have only one public IP address (used in a Cisco IOS® router to perform PAT on all traffic) and need to pass an IPSec tunnel through it.
For VPN Gateways that run Cisco IOS Software Releases earlier than 12.2(13)T, the IPSec passthrough feature is needed on the router that performs PAT to allow Encapsulating Security Payload (ESP) through.
Note: This feature is known as IPSec through Network Address Translation (NAT) support in Software Advisory (registered customers only) .
In order to initiate the tunnel from the local (PATed) peer, no configuration is needed. In order to initiate the tunnel from the remote peer, these commands are needed:
  • ip nat inside source static esp inside_ip interface interface
  • ip nat inside source static udp inside_ip 500 interface interface 500
For VPN Gateways that run a Cisco IOS Software Release later than 12.2(13)T, IPSec traffic is encapsulated into User Data Protocol (UDP) port 4500 packets. This feature is known as IPSec NAT Transparency . In order to initiate the tunnel from the local (PATed) peer, no configuration is needed.
In order to initiate the tunnel from the remote peer, these commands are needed:
  • ip nat inside source static udp inside_ip 4500 interface interface 4500
  • ip nat inside source static udp inside_ip 500 interface interface 500
Issue the no crypto ipsec nat-transparency udp-encaps command to disable IPSec NAT Transparency.

Prerequisites

Requirements

There are no specific requirements for this document.

Components Used

The information in this document is based on Cisco IOS Software Release 12.3(7)T1.
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.

Conventions

For more information on document conventions, refer to Cisco Technical Tips Conventions.

Configure

In this section, you are presented with the information to configure the features described in this document.

Network Diagram

This document uses this network setup:
ios_pat_ipsec_tunnel.gif

Configurations with IPSec NAT Transparancy

This document uses these configurations:
VPN-Gateway1
VPN-Gateway1#show running-config 
Building configuration...

Current configuration : 1017 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname VPN-Gateway1
!


!--- VPN Gateway1 and VPN Gateway2 can be any devices that 
!--- perform IPSec. For detailed information on configuring IPSec 
!--- refer to IPSec Technology Support Information. 
!--- IPSec configuration between VPN Gateway1 and VPN Gateway2
!--- is beyond the scope of this document. 


boot-start-marker
boot-end-marker
!
!
clock timezone EST 0
no aaa new-model
ip subnet-zero
!
!
ip audit po max-events 100
no ftp-server write-enable
!
!
!         
! 
!

!--- IKE policies (phase 1).

crypto isakmp policy 10
 authentication pre-share
crypto isakmp key cisco123 address 209.165.201.2
!
!
crypto ipsec transform-set basic esp-des esp-md5-hmac 
!

!--- IPSec policies (phase 1).

crypto map mymap 10 ipsec-isakmp 
 set peer 209.165.201.2
 set transform-set basic 
 match address 101
!
!
!
interface Ethernet0/0
 ip address 192.168.1.1 255.255.255.0
!
interface Serial1/0
 ip address 209.165.200.2 255.255.255.252
 serial restart-delay 0
 crypto map mymap
!
ip classless
ip route 0.0.0.0 0.0.0.0 209.165.200.1
no ip http server
no ip http secure-server
!
!
!
access-list 101 permit ip 192.168.1.0 0.0.0.255 172.16.2.0 0.0.0.255
access-list 101 remark Crypto ACL
!
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
!
!
end
PAT-Router
PAT-Router#show running-config 
Building configuration...

Current configuration : 971 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname PAT-Router
!
boot-start-marker
boot-end-marker
!
!
clock timezone EST 0
no aaa new-model
ip subnet-zero
!
!
ip audit po max-events 100
no ftp-server write-enable
!
!
!         
! 
no crypto isakmp enable
!
!
!
interface Ethernet0/0
 ip address 172.16.1.1 255.255.255.0

!--- This declares the interface as inside for NAT purposes.

 ip nat inside
!
interface Serial1/0
 ip address 209.165.201.2 255.255.255.224

!--- This declares the interface as
!--- outside for NAT purposes.

 ip nat outside
 serial restart-delay 0
!
ip classless
ip route 0.0.0.0 0.0.0.0 209.165.201.1
ip route 172.16.0.0 255.255.0.0 172.16.1.2
no ip http server
no ip http secure-server
!
ip nat inside source list 1 interface Serial1/0 overload

!--- This allows PAT to be used for regular Internet traffic. 

ip nat inside source static udp 172.16.1.2 4500 interface Serial1/0 4500

!--- This permits IPSec traffic destined for the Serial1/0
!--- interface to be sent to the inside IP address 172.16.1.2.

ip nat inside source static udp 172.16.1.2 500 interface Serial1/0 500

!--- This allows UDP traffic for the Serial1/0 interface to be
!--- statically mapped to the inside IP address 172.16.1.2. 
!--- This is required for the Internet Security Association 
!--- and Key Management Protocol (ISAKMP) negotiation to be 
!--- initiated from VPN-Gateway1 to VPN-Gateway2.

!
!
access-list 1 permit 172.16.0.0 0.0.255.255
!
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
!
!
end
VPN-Gateway2
VPN-Gateway2#show running-config
Building configuration...

Current configuration : 986 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname VPN-Gateway2
!


!--- VPN Gateway1 and VPN Gateway2 can be any devices
!--- that perform IPSec. For detailed information on 
!--- IPSec configuration refer to IPSec Technology Support Information. 
!--- IPSec configuration between VPN Gateway1 and VPN Gateway2
!--- is beyond the scope of this document. 


boot-start-marker
boot-end-marker
!
!
clock timezone EST 0
no aaa new-model
ip subnet-zero
!
!
ip audit po max-events 100
no ftp-server write-enable
!
!
!         
! 
!

!--- IKE policies (phase 1).

crypto isakmp policy 10
 authentication pre-share
crypto isakmp key cisco123 address 209.165.200.2
!
!
crypto ipsec transform-set basic esp-des esp-md5-hmac 
!

!--- IPSec policies (phase 1).

crypto map mymap 10 ipsec-isakmp 
 set peer 209.165.200.2
 set transform-set basic 
 match address 101
!
!
!
interface Ethernet0/0
 ip address 172.16.1.2 255.255.255.0
 crypto map mymap
!
interface Ethernet1/0
 ip address 172.16.2.1 255.255.255.0
!         
ip classless
ip route 0.0.0.0 0.0.0.0 172.16.1.1
no ip http server
no ip http secure-server
!
!
!
access-list 101 permit ip 172.16.2.0 0.0.0.255 192.168.1.0 0.0.0.255
access-list 101 remark Crypto ACL
!
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
!
!
end

Configurations without IPSec NAT Transparency

VPN-Gateway1
VPN-Gateway1#show running-config 
Building configuration...

Current configuration : 1017 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname VPN-Gateway1
!


!--- VPN Gateway1 and VPN Gateway2 can be any devices
!--- that perform IPSec. For detailed information on 
!--- IPSec configuration refer to IPSec Technology Support Information. 
!--- IPSec configuration between VPN Gateway1 and VPN Gateway2
!--- is beyond the scope of this document. 


boot-start-marker
boot-end-marker
!
!
clock timezone EST 0
no aaa new-model
ip subnet-zero
!
!
ip audit po max-events 100
no ftp-server write-enable
!
!
!         
! 
!

!--- IKE policies (phase 1).

crypto isakmp policy 10
 authentication pre-share
crypto isakmp key cisco123 address 209.165.201.2
!
!
crypto ipsec transform-set basic esp-des esp-md5-hmac 
!

!--- IPSec policies (phase 1).

crypto map mymap 10 ipsec-isakmp 
 set peer 209.165.201.2
 set transform-set basic 
 match address 101
!
!
!
interface Ethernet0/0
 ip address 192.168.1.1 255.255.255.0
!
interface Serial1/0
 ip address 209.165.200.2 255.255.255.252
 serial restart-delay 0
 crypto map mymap
!
ip classless
ip route 0.0.0.0 0.0.0.0 209.165.200.1
no ip http server
no ip http secure-server
!
!
!
access-list 101 permit ip 192.168.1.0 0.0.0.255 172.16.2.0 0.0.0.255
access-list 101 remark Crypto ACL
!
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
!
!
end
PAT-Router
PAT-Router#show running-config 
Building configuration...

Current configuration : 971 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname PAT-Router
!
boot-start-marker
boot-end-marker
!
!
clock timezone EST 0
no aaa new-model
ip subnet-zero
!
!
ip audit po max-events 100
no ftp-server write-enable
!
!
!         
! 
no crypto isakmp enable
!
!
!
interface Ethernet0/0
 ip address 172.16.1.1 255.255.255.0

!--- This declares the interface as inside for NAT purposes.

 ip nat inside
!
interface Serial1/0
 ip address 209.165.201.2 255.255.255.224

!--- This declares the interface as 
!--- outside for NAT purposes.

 ip nat outside
 serial restart-delay 0
!
ip classless
ip route 0.0.0.0 0.0.0.0 209.165.201.1
ip route 172.16.0.0 255.255.0.0 172.16.1.2
no ip http server
no ip http secure-server
!
ip nat inside source list 1 interface Serial1/0 overload

!--- This allows PAT to be used for regular Internet traffic.
 
ip nat inside source static esp 172.16.1.2 interface Serial1/0

!--- This permits the IPSec ESP tunnel mode 
!--- destined for the Serial1/0 interface to be sent 
!--- to the inside IP address 172.16.1.2. The "esp"
!--- option allows a single ESP tunnel-mode 
!--- VPN setup to be possible.

ip nat inside source static udp 172.16.1.2 500 interface Serial1/0 500

!--- This allows UDP traffic for the Serial1/0 
!--- interface to be statically mapped to the inside 
!--- IP address 172.16.1.2. This is required 
!--- for the ISAKMP negotiation to be initiated 
!--- from VPN-Gateway1 to VPN-Gateway2.

!
!
access-list 1 permit 172.16.0.0 0.0.255.255
!
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
!
!
end 
VPN-Gateway2
VPN-Gateway2#show running-config
Building configuration...

Current configuration : 986 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname VPN-Gateway2
!


!--- VPN Gateway1 and VPN Gateway2 can be any devices
!--- that perform IPSec. For detailed information on 
!--- IPSec configuration refer to IPSec Technology Support Information. 
!--- IPSec configuration between VPN Gateway1 and VPN Gateway2
!--- is beyond the scope of this document. 


boot-start-marker
boot-end-marker
!
!
clock timezone EST 0
no aaa new-model
ip subnet-zero
!
!
ip audit po max-events 100
no ftp-server write-enable
!
!
!         
! 
!

!--- IKE policies (phase 1).

crypto isakmp policy 10
 authentication pre-share
crypto isakmp key cisco123 address 209.165.200.2
!
!
crypto ipsec transform-set basic esp-des esp-md5-hmac
no crypto ipsec nat-transparency udp-encaps 
!

!--- IPSec policies (phase 1).

crypto map mymap 10 ipsec-isakmp 
 set peer 209.165.200.2
 set transform-set basic 
 match address 101
!
!
!
interface Ethernet0/0
 ip address 172.16.1.2 255.255.255.0
 crypto map mymap
!
interface Ethernet1/0
 ip address 172.16.2.1 255.255.255.0
!         
ip classless
ip route 0.0.0.0 0.0.0.0 172.16.1.1
no ip http server
no ip http secure-server
!
!
!
access-list 101 permit ip 172.16.2.0 0.0.0.255 192.168.1.0 0.0.0.255
access-list 101 remark Crypto ACL
!
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
!
!
end

Verify

These sections provide information you can use to confirm your configuration is working properly.
Certain show commands are supported by the Output Interpreter Tool (registered customers only) , which allows you to view an analysis of show command output.

Verify with IPSec NAT Transparency

  • show crypto isakmp sa—Displays all current Internet Key Exchange (IKE) security associations (SA) at a peer.
    VPN-Gateway1#show crypto isakmp sa
    dst             src             state          conn-id slot
    209.165.200.2   209.165.201.2   QM_IDLE              1    0
    
    
    VPN-Gateway2#show crypto isakmp sa
    dst             src             state          conn-id slot
    209.165.200.2   172.16.1.2      QM_IDLE              1    0
  • show crypto ipsec sa—Displays IPSec SAs built between peers.
    VPN-Gateway1#show crypto ipsec sa
    
     
    !--- This command is issued after a ping
     !--- is attempted from PC2 to PC1.
    
    
    interface: Serial1/0
        Crypto map tag: mymap, local addr. 209.165.200.2
    
       protected vrf: 
       local  ident (addr/mask/prot/port): (192.168.1.0/255.255.255.0/0/0)
       remote ident (addr/mask/prot/port): (172.16.2.0/255.255.255.0/0/0)
       current_peer: 209.165.201.2:4500
         PERMIT, flags={origin_is_acl,}
        #pkts encaps: 6, #pkts encrypt: 6, #pkts digest: 6
        #pkts decaps: 6, #pkts decrypt: 6, #pkts verify: 6
        #pkts compressed: 0, #pkts decompressed: 0
        #pkts not compressed: 0, #pkts compr. failed: 0
        #pkts not decompressed: 0, #pkts decompress failed: 0
        #send errors 0, #recv errors 0
    
         local crypto endpt.: 209.165.200.2, remote crypto endpt.: 209.165.201.2
         path mtu 1500, media mtu 1500
         current outbound spi: 9CCA0619
    
         inbound esp sas:
          spi: 0x4E6B990F(1315674383)
            transform: esp-des esp-md5-hmac ,
            in use settings ={Tunnel UDP-Encaps, }
            slot: 0, conn id: 2000, flow_id: 5, crypto map: mymap
            crypto engine type: Software, engine_id: 1
            sa timing: remaining key lifetime (k/sec): (4602622/3489)
            ike_cookies: 8973C578 9C7DEB45 5C9BE6DC 7F737D09
            IV size: 8 bytes
            replay detection support: Y
    
         inbound ah sas:
    
         inbound pcp sas:
    
         outbound esp sas:
          spi: 0x9CCA0619(2630485529)
            transform: esp-des esp-md5-hmac ,
            in use settings ={Tunnel UDP-Encaps, }
            slot: 0, conn id: 2001, flow_id: 6, crypto map: mymap
            crypto engine type: Software, engine_id: 1
            sa timing: remaining key lifetime (k/sec): (4602622/3489)
            ike_cookies: 8973C578 9C7DEB45 5C9BE6DC 7F737D09
            IV size: 8 bytes
            replay detection support: Y
    
         outbound ah sas:
    
         outbound pcp sas:
    
    
    VPN-Gateway2#show crypto ipsec sa
    
     
    !--- This command is issued after a ping
     !--- is attempted from PC2 to PC1.
    
    
    interface: Ethernet0/0
        Crypto map tag: mymap, local addr. 172.16.1.2
    
       protected vrf: 
       local  ident (addr/mask/prot/port): (172.16.2.0/255.255.255.0/0/0)
       remote ident (addr/mask/prot/port): (192.168.1.0/255.255.255.0/0/0)
       current_peer: 209.165.200.2:4500
         PERMIT, flags={origin_is_acl,}
        #pkts encaps: 23, #pkts encrypt: 23, #pkts digest: 23
        #pkts decaps: 16, #pkts decrypt: 16, #pkts verify: 16
        #pkts compressed: 0, #pkts decompressed: 0
        #pkts not compressed: 0, #pkts compr. failed: 0
        #pkts not decompressed: 0, #pkts decompress failed: 0
        #send errors 7, #recv errors 0
    
         local crypto endpt.: 172.16.1.2, remote crypto endpt.: 209.165.200.2
         path mtu 1500, media mtu 1500
         current outbound spi: 4E6B990F
    
         inbound esp sas:
          spi: 0x9CCA0619(2630485529)
            transform: esp-des esp-md5-hmac ,
            in use settings ={Tunnel UDP-Encaps, }
            slot: 0, conn id: 2000, flow_id: 1, crypto map: mymap
            crypto engine type: Software, engine_id: 1
            sa timing: remaining key lifetime (k/sec): (4384024/3481)
            ike_cookies: 5C9BE6DC 7F737D09 8973C578 9C7DEB45
            IV size: 8 bytes
            replay detection support: Y
    
         inbound ah sas:
    
         inbound pcp sas:
    
         outbound esp sas:
          spi: 0x4E6B990F(1315674383)
            transform: esp-des esp-md5-hmac ,
            in use settings ={Tunnel UDP-Encaps, }
            slot: 0, conn id: 2001, flow_id: 2, crypto map: mymap
            crypto engine type: Software, engine_id: 1
            sa timing: remaining key lifetime (k/sec): (4384024/3481)
            ike_cookies: 5C9BE6DC 7F737D09 8973C578 9C7DEB45
            IV size: 8 bytes
            replay detection support: Y
    
         outbound ah sas:
    
         outbound pcp sas:
  • show ip nat translations—Displays active NAT translations.
    PAT-Router#show ip nat translations
    Pro Inside global      Inside local       Outside local      Outside global
    udp 209.165.201.2:500  172.16.1.2:500     ---                ---
    udp 209.165.201.2:4500 172.16.1.2:4500    ---                ---

Verify without IPSec NAT Transparency

  • show crypto isakmp sa—Displays all current IKE SAs at a peer.
    VPN-Gateway1#show crypto isakmp sa
    dst             src             state          conn-id slot
    209.165.200.2   209.165.201.2   QM_IDLE              1    0
    
    
    VPN-Gateway2#show crypto isakmp sa
    dst             src             state          conn-id slot
    209.165.200.2   172.16.1.2      QM_IDLE              1    0
  • show crypto ipsec sa—Displays IPSec SAs built between peers.
    VPN-Gateway1#show crypto ipsec sa
    
     
    !--- This command is issued after a ping
     !--- is attempted from PC2 to PC1.
    
    
    interface: Serial1/0
        Crypto map tag: mymap, local addr. 209.165.200.2
    
       protected vrf: 
       local  ident (addr/mask/prot/port): (192.168.1.0/255.255.255.0/0/0)
       remote ident (addr/mask/prot/port): (172.16.2.0/255.255.255.0/0/0)
       current_peer: 209.165.201.2:500
         PERMIT, flags={origin_is_acl,}
        #pkts encaps: 21, #pkts encrypt: 21, #pkts digest: 21
        #pkts decaps: 15, #pkts decrypt: 15, #pkts verify: 15
        #pkts compressed: 0, #pkts decompressed: 0
        #pkts not compressed: 0, #pkts compr. failed: 0
        #pkts not decompressed: 0, #pkts decompress failed: 0
        #send errors 4, #recv errors 0
    
         local crypto endpt.: 209.165.200.2, remote crypto endpt.: 209.165.201.2
         path mtu 1500, media mtu 1500
         current outbound spi: E89A0245
    
         inbound esp sas:
          spi: 0xB5F867BC(3052955580)
            transform: esp-des esp-md5-hmac ,
            in use settings ={Tunnel, }
            slot: 0, conn id: 2000, flow_id: 7, crypto map: mymap
            crypto engine type: Software, engine_id: 1
            sa timing: remaining key lifetime (k/sec): (4538665/3553)
            ike_cookies: 8973C578 DD91CB42 5C9BE6DC 63813771
            IV size: 8 bytes
            replay detection support: Y
    
         inbound ah sas:
    
         inbound pcp sas:
    
         outbound esp sas:
          spi: 0xE89A0245(3902407237)
            transform: esp-des esp-md5-hmac ,
            in use settings ={Tunnel, }
            slot: 0, conn id: 2001, flow_id: 8, crypto map: mymap
            crypto engine type: Software, engine_id: 1
            sa timing: remaining key lifetime (k/sec): (4538665/3553)
            ike_cookies: 8973C578 DD91CB42 5C9BE6DC 63813771
            IV size: 8 bytes
            replay detection support: Y
    
         outbound ah sas:
    
         outbound pcp sas:
    
    
    VPN-Gateway2#show crypto ipsec sa
    
     
    !--- This command is issued after a ping
     !--- is attempted from PC2 to PC1.
    
    
    interface: Ethernet0/0
        Crypto map tag: mymap, local addr. 172.16.1.2
    
       protected vrf: 
       local  ident (addr/mask/prot/port): (172.16.2.0/255.255.255.0/0/0)
       remote ident (addr/mask/prot/port): (192.168.1.0/255.255.255.0/0/0)
       current_peer: 209.165.200.2:500
         PERMIT, flags={origin_is_acl,}
        #pkts encaps: 5, #pkts encrypt: 5, #pkts digest: 5
        #pkts decaps: 5, #pkts decrypt: 5, #pkts verify: 5
        #pkts compressed: 0, #pkts decompressed: 0
        #pkts not compressed: 0, #pkts compr. failed: 0
        #pkts not decompressed: 0, #pkts decompress failed: 0
        #send errors 1, #recv errors 0
    
         local crypto endpt.: 172.16.1.2, remote crypto endpt.: 209.165.200.2
         path mtu 1500, media mtu 1500
         current outbound spi: B5F867BC
    
         inbound esp sas:
          spi: 0xE89A0245(3902407237)
            transform: esp-des esp-md5-hmac ,
            in use settings ={Tunnel, }
            slot: 0, conn id: 2000, flow_id: 3, crypto map: mymap
            crypto engine type: Software, engine_id: 1
            sa timing: remaining key lifetime (k/sec): (4572084/3561)
            ike_cookies: 5C9BE6DC 63813771 8973C578 DD91CB42
            IV size: 8 bytes
            replay detection support: Y
    
         inbound ah sas:
    
         inbound pcp sas:
    
         outbound esp sas:
          spi: 0xB5F867BC(3052955580)
            transform: esp-des esp-md5-hmac ,
            in use settings ={Tunnel, }
            slot: 0, conn id: 2001, flow_id: 4, crypto map: mymap
            crypto engine type: Software, engine_id: 1
            sa timing: remaining key lifetime (k/sec): (4572084/3561)
            ike_cookies: 5C9BE6DC 63813771 8973C578 DD91CB42
            IV size: 8 bytes
            replay detection support: Y
    
         outbound ah sas:
    
         outbound pcp sas:
  • show ip nat translations—Displays active NAT translations.
    PAT-Router#show ip nat translations
    Pro Inside global      Inside local       Outside local      Outside global
    udp 209.165.201.2:500  172.16.1.2:500     ---                ---
    esp 209.165.201.2:0    172.16.1.2:0       ---                ---

Comentarios

Entradas populares de este blog

Guía de herramientas básicas para estudiantes: 31 apps y webs imprescindibles para ayudarte con los estudios

Comando FOR para archivos BAT

How to Setup and Configure Your Own GitLab Server on Ubuntu 20.04