EdgeRouter - IPsec Route-Based (VTI) Site-to-Site VPN to Cisco ISR

 Overview


Readers will learn how to configure a Route-Based Site-to-Site IPsec VPN between an EdgeRouter and a Cisco ISR using static routing.

A Route-Based VPN is characterized by the usage of Virtual Tunnel Interfaces (VTIs) and routing entries. This type of VPN differs from a Policy-Based VPN which relies on a definition of local and remote subnets (proxy IDs). This example focuses on using static routing, however it is also possible to run a dynamic routing protocol such as OSPF over the tunnel.

book_25x25.png    NOTES & REQUIREMENTS:

Applicable to EdgeOS 1.9.7 + firmware in all EdgeRouter models. Knowledge of the Command Line Interface (CLI), Cisco IOS, and advanced networking knowledge is required. Please see the Related Articles below for more information and see the attachments for the configurations used in this article.

 

Equipment used in this article:

- EdgeRouter-X (ER-X)

Cisco ISR

- Test clients behind the peers (Host1 and Server1)

Table of Contents


  1. Network Diagram
  2. Steps: Route-Based VPN
  3. Steps: Cisco ISR VPN
  4. Steps: Testing & Verification
  5. Related Articles

Network Diagram


Back to Top

The network topology is shown below. The following interfaces are in use on the EdgeRouter and the Cisco ISR:

ER-X

  1. eth0 (WAN) - 203.0.113.1
  2. eth1 (LAN) - 192.168.1.1/24
  3. vti0 - 10.255.12.1/30

 Cisco ISR

  1. gi0/0 (WAN) - 192.0.2.1
  2. gi0/1 (LAN) - 172.16.1.1/24
  3. tun0 - 10.255.12.2/30

image1.png


Steps: Route-Based VPN


Back to Top

For the purpose of this article it is assumed that the routing and interface configuration is already in place and that reachability has been tested.

The UDP ports and protocols relevant to IPsec are:

  1. UDP 500 (IKE)
  2. ESP (Protocol 50)
  3. UDP 4500 (NAT-T)

The type of VPN that will be created is called a Static VTI over IPsec tunnel (IPIP encapsulation). This means that packets will be routed over a VTI interface (vti0) and encrypted using IPsec afterwards. Static routes will be used to facilitate routing between the sites.

The first part of the configuration focuses on the ER, afterwards the VPN will be setup on the ISR.

CLI_circle.png  CLI STEPS: Access the command line interface (CLI). You can do this using the CLI button in the GUI or by using a program such as PuTTY.

1. Enter configuration mode.

configure

2. Exclude IPsec traffic from NAT and allow the automatic creation of the firewall rules.

set vpn ipsec auto-firewall-nat-exclude enable

3. Create the IKE proposal (P1) and Security Associations (SAs).

set vpn ipsec ike-group FOO0 lifetime 86400
set vpn ipsec ike-group FOO0 proposal 1 dh-group 14
set vpn ipsec ike-group FOO0 proposal 1 encryption aes256
set vpn ipsec ike-group FOO0 proposal 1 hash sha256

4. Create the ESP proposal (P2) and Security Associations (SAs).

set vpn ipsec esp-group FOO0 lifetime 43200
set vpn ipsec esp-group FOO0 pfs disable
set vpn ipsec esp-group FOO0 proposal 1 encryption aes128
set vpn ipsec esp-group FOO0 proposal 1 hash md5
info_i_25x25.png Note: The choices for SAs in this example are based on optimizing the VPN for performance, stability and security. The IKE proposal focuses on security (AES256 + SHA256), whereas the ESP proposal focuses on performance (AES128 + MD5). Whatever set of SAs are chosen, make sure that the settings for Phase 1 (P1) and Phase 2 (P2) match on both sides of the connection.

5. Define the peer address and the pre-shared-key (replace <secret> with your desired passphrase).

set vpn ipsec site-to-site peer 192.0.2.1 authentication mode pre-shared-secret
set vpn ipsec site-to-site peer 192.0.2.1 authentication pre-shared-secret <secret>
set vpn ipsec site-to-site peer 192.0.2.1 description IPsec

6. Define the local source address (public IP) of the Site-to-Site VPN connection.

set vpn ipsec site-to-site peer 192.0.2.1 local-address 203.0.113.1
info_i_25x25.png Note: Currently the Route-Based VTI configuration does NOT support dynamic peer addresses or Fully Qualified Domain Names (FQDN) used by Dynamic DNS (DynDNS). The VTI endpoints need to connect to known IP addresses and do NOT work with local-address any or peer 0.0.0.0.

7. Link the IKE proposal to the Site-to-Site connection.

set vpn ipsec site-to-site peer 192.0.2.1 ike-group FOO0

8. Link the Site-to-Site connection to a VTI interface and link the ESP proposal.

set vpn ipsec site-to-site peer 192.0.2.1 vti bind vti0
set vpn ipsec site-to-site peer 192.0.2.1 vti esp-group FOO0

9. (Optional) Enable the IPsec offloading feature to increase ESP (not IKE) performance.

set system offload ipsec enable (this requires a reboot to become active)

10. Create a VTI to be used by the VPN and assign it an IP address.

set interfaces vti vti0 address 10.255.12.1/30
info_i_25x25.png Note: It is strongly recommended to use a RFC1918 IP address for the tunnel interface. This IP address should not exist anywhere else on the router or in the routing table.

11. (Optional) Lower the MTU settings on the VTI interface.

set interfaces vti vti0 mtu 1400
info_i_25x25.png Note: Unlike GRE tunnels, VTI interfaces do not add an additional 24 bytes of overhead. The MTU will be automatically lowered to accommodate the IPsec overhead. In some cases however, connections (such as HTTPS and SSH) can fail to establish over the tunnel. In these cases you can choose to lower the MTU value of the tunnel. A value of 1400 is a good baseline that prevents fragmentation. You may choose to increase or decrease this MTU based on your specific scenario.

12. Create routing entries for the remote subnet(s) pointing towards the VTI.

set protocols static interface-route 172.16.1.0/24 next-hop-interface vti0

13. Remove the IPsec tunnel(s).

delete vpn ipsec site-to-site peer 192.0.2.1 tunnel 1

14. Link the IPsec peer configuration to the VTI interface created earlier.

set vpn ipsec site-to-site peer 192.0.2.1 vti bind vti0
set vpn ipsec site-to-site peer 192.0.2.1 vti esp-group FOO0

15. (Optional) Enable the IPsec offloading feature to increase ESP (not IKE) performance.

set system offload ipsec enable (this requires a reboot to become active)

16. Commit the changes.

commit

17. Save the configuration.

save

Steps: Cisco ISR VPN


Back to Top

Please make sure that the latest stable version of IOS is being used and that the device is capable of reaching the internet. The Cisco side of the Site-to-Site VPN connection is based on the following IPsec article: IPsec Virtual Tunnel Interfaces

CLI_circle.png  CLI STEPS: Access the IOS command line interface (CLI). 

1. Enter configuration mode.

configure terminal

2. Create the IKE policy (ISAKMP) matching the defined SAs on the EdgeRouter.

crypto isakmp policy 100
encr aes 256
hash sha256
authentication pre-share
group 14
lifetime 86400

3. Create the IPsec transform set (IPsec_TS) matching the defined SAs on the EdgeRouter.

crypto ipsec transform-set IPsec_TS esp-aes 128 esp-md5-hmac

4. Define the peer address and the pre-shared-key (replace <secret> with your desired passphrase).

crypto isakmp key <secret> address 203.0.113.1

5. Create the IPsec profile (IPsec_PF) and link it to the IPsec transform set, while also defining the P2 lifetime.

crypto ipsec profile IPsec_PF
set transform-set IPsec_TS
set security-association lifetime seconds 43200

6. Create a tunnel (tun) interface and link it to the IPsec profile, while also defining the tunnel mode and source/destination addresses.

interface tun0
ip address 10.255.12.2 255.255.255.252
tunnel source gi0/0
tunnel destination 203.0.113.1
tunnel protection ipsec profile IPsec_PF
tunnel mode ipsec ipv4

7. (Optional) Lower the MTU settings on the tun0 interface.

interface tun0
ip mtu 1400

8. Write the changes to the startup configuration.

copy running-config startup-config

Testing & Verification


Back to Top

After configuring the IPsec VPN, verify the connection/state using the following commands.

1. Verify the IPsec Security Associations (SAs) and status on the ER:

show vpn ipsec sa
peer-192.0.2.1-tunnel-vti: #4, ESTABLISHED, IKEv1, 24d45792c4976ca4:f4b8de413b632a7c

 local  '203.0.113.1' @ 203.0.113.1
 remote '192.0.2.1' @ 192.0.2.1
 AES_CBC-256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_2048
 established 13s ago, reauth in 85578s
 peer-192.0.2.1-tunnel-vti: #1, INSTALLED, TUNNEL, ESP:AES_CBC-128/HMAC_MD5_96
   installed 13 ago, rekeying in 42249s, expires in 43187s
   in  cf09bc59,    500 bytes,     5 packets,     5s ago
   out 769b07da,    500 bytes,     5 packets,     5s ago
   local  0.0.0.0/0
   remote 0.0.0.0/0

sudo ipsec statusall
Status of IKE charon daemon (strongSwan 5.2.2, Linux 3.10.14-UBNT, mips):

 uptime: 22 minutes, since Mar 12 09:34:36 2017
 malloc: sbrk 376832, mmap 0, used 272632, free 104200
 worker threads: 11 of 16 idle, 5/0/0/0 working, job queue: 0/0/0/0, scheduled: 8
Listening IP addresses:
 203.0.113.1
 192.168.1.1
 10.255.12.1
Connections:
peer-192.0.2.1-tunnel-vti:  203.0.113.1...192.0.2.1  IKEv1
peer-192.0.2.1-tunnel-vti:   local:  [203.0.113.1] uses pre-shared key authentication
peer-192.0.2.1-tunnel-vti:   remote: [192.0.2.1] uses pre-shared key authentication
peer-192.0.2.1-tunnel-vti:   child:  0.0.0.0/0 === 0.0.0.0/0 TUNNEL
Routed Connections:
peer-192.0.2.1-tunnel-vti{1}:  ROUTED, TUNNEL
peer-192.0.2.1-tunnel-vti{1}:   0.0.0.0/0 === 0.0.0.0/0
Security Associations (1 up, 0 connecting):
peer-192.0.2.1-tunnel-vti[4]: ESTABLISHED 74 seconds ago, 203.0.113.1[203.0.113.1]...192.0.2.1[192.0.2.1]
peer-192.0.2.1-tunnel-vti[4]: IKEv1 SPIs: 24d45792c4976ca4_i f4b8de413b632a7c_r*, pre-shared key reauthentication in 23 hours
peer-192.0.2.1-tunnel-vti[4]: IKE proposal: AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_2048
peer-192.0.2.1-tunnel-vti{1}:  INSTALLED, TUNNEL, ESP SPIs: cf09bc59_i 769b07da_o
peer-192.0.2.1-tunnel-vti{1}:  AES_CBC_128/HMAC_MD5_96, 500 bytes_i (5 pkts, 66s ago), 500 bytes_o (5 pkts, 66s ago)
peer-192.0.2.1-tunnel-vti{1}:   0.0.0.0/0 === 0.0.0.0/0

2. Verify the ER IPsec strongSwan configuration:

sudo cat /etc/ipsec.conf
# generated by /opt/vyatta/sbin/vpn-config.pl


config setup

conn %default
       keyexchange=ikev1

conn peer-192.0.2.1-tunnel-vti
       left=203.0.113.1
       right=192.0.2.1
       leftsubnet=0.0.0.0/0
       rightsubnet=0.0.0.0/0
       ike=aes256-sha256-modp2048!
       keyexchange=ikev1
       ikelifetime=86400s
       esp=aes128-md5!
       keylife=43200s
       rekeymargin=540s
       type=tunnel
       compress=no
       authby=secret
       mark=9437185
       auto=route
       keyingtries=%forever
#conn peer-192.0.2.1-tunnel-vti

3. Capture the arrival of IKE traffic on the ER external WAN interface:

sudo tcpdump -i eth0 -n udp dst port 500   
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
IP 203.0.113.1.500 > 192.0.2.1.500: isakmp: phase 1 I ident
IP 192.0.2.1.500 > 203.0.113.1.500: isakmp: phase 1 R ident
IP 203.0.113.1.500 > 192.0.2.1.500: isakmp: phase 1 I ident[E]
IP 192.0.2.1.500 > 203.0.113.1.500: isakmp: phase 1 R ident[E]
IP 203.0.113.1.500 > 192.0.2.1.500: isakmp: phase 2/others I oakley-quick[E]
IP 192.0.2.1.500 > 203.0.113.1.500: isakmp: phase 2/others R oakley-quick[E]
info_i_25x25.png Note: This is a live capture. If there is no output that means that the traffic is either not being generated on the client, or there is something blocking the traffic upstream.

4. Capture the ER IPsec VPN logs:

sudo swanctl --log
[IKE] initiating Main Mode IKE_SA peer-192.0.2.1-tunnel-1[1] to 192.0.2.1

[ENC] generating ID_PROT request 0 [ SA V V V V ]
[NET] sending packet: from 203.0.113.1[500] to 192.0.2.1[500] (160 bytes)
[NET] received packet: from 192.0.2.1[500] to 203.0.113.1[500] (108 bytes)
[ENC] parsed ID_PROT response 0 [ SA V ]
[IKE] received NAT-T (RFC 3947) vendor ID
[ENC] generating ID_PROT request 0 [ KE No NAT-D NAT-D ]
[ENC] parsed ID_PROT response 0 [ KE No V V V V NAT-D NAT-D ]
[ENC] generating ID_PROT request 0 [ ID HASH N(INITIAL_CONTACT) ]
[ENC] parsed ID_PROT response 0 [ ID HASH ]
[IKE] IKE_SA peer-192.0.2.1-tunnel-1[1] established between 203.0.113.1[203.0.113.1]...192.0.2.1[192.0.2.1]
[ENC] generating QUICK_MODE request 561157166 [ HASH SA No ID ID ]
[ENC] parsed QUICK_MODE response 561157166 [ HASH SA No ID ID N((24576)) ]
[IKE] CHILD_SA peer-192.0.2.1-tunnel-vti{1} established with SPIs cad56e88_i 86968a35_o and TS 0.0.0.0/0 === 0.0.0.0/0
info_i_25x25.png Note: This is also live capture. If there is no output that means that the traffic is either not being allowed through the firewall. Alternatively you can use the show vpn log | no-more command to view the entire IPsec log history.

5. Verify the ER state of the tunnel and capture the traffic that is sent over the tunnel:

show interfaces vti vti0
vti0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1400 qdisc noqueue state UNKNOWN group default

   link/ipip 203.0.113.1 peer 192.0.2.1
   inet 10.255.12.1/30 scope global vti0
      valid_lft forever preferred_lft forever

   RX:  bytes    packets     errors    dropped    overrun      mcast
         1600         19          0          0          0          0
   TX:  bytes    packets     errors    dropped    carrier collisions
         1332         14          0          0          0          0

show interfaces vti vti0 capture
IP 172.16.1.10 > 192.168.1.10: ICMP echo request, id 12993, seq 18, length 64

IP 192.168.1.10 > 172.16.1.10: ICMP echo reply, id 12993, seq 18, length 64
IP 172.16.1.10 > 192.168.1.10: ICMP echo request, id 12993, seq 19, length 64
IP 192.168.1.10 > 172.16.1.10: ICMP echo reply, id 12993, seq 19, length 64

6. Verify the IPsec Security Associations (SAs) and statistics on the ISR:

show crypto isakmp sa
IPv4 Crypto ISAKMP SA

dst             src             state          conn-id status
192.0.2.1       203.0.113.1     QM_IDLE           1002 ACTIVE

show crypto isakmp sa detail
IPv4 Crypto ISAKMP SA

C-id  Local           Remote          I-VRF  Status Encr Hash   Auth DH Lifetime Cap.
1002  192.0.2.1       203.0.113.1            ACTIVE aes  sha256 psk  14 23:58:38  

show crypto engine connections active
Crypto Engine Connections

  ID  Type    Algorithm           Encrypt  Decrypt LastSeqN IP-Address
5  IPsec   AES+MD5                   0        3        3 192.0.2.1
  6  IPsec   AES+MD5                   3        0        0 192.0.2.1
1002  IKE     SHA256+AES256             0        0        0 192.0.2.1

show crypto ipsec sa
interface: Tunnel0
   Crypto map tag: Tunnel0-head-0, local addr 192.0.2.1

  protected vrf: (none)
  local  ident (addr/mask/prot/port): (0.0.0.0/0.0.0.0/0/0)
  remote ident (addr/mask/prot/port): (0.0.0.0/0.0.0.0/0/0)
  current_peer 203.0.113.1 port 500
    PERMIT, flags={origin_is_acl,}
   #pkts encaps: 22, #pkts encrypt: 22, #pkts digest: 22
   #pkts decaps: 36, #pkts decrypt: 36, #pkts verify: 36
   #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.: 192.0.2.1, remote crypto endpt.: 203.0.113.1
    path mtu 1500, ip mtu 1500, ip mtu idb GigabitEthernet0/0
    current outbound spi: 0xCEFC9AFE(3472661246)
    PFS (Y/N): N, DH group: none

    inbound esp sas:
     spi: 0xF98EABDE(4186876894)
       transform: esp-aes esp-md5-hmac ,
       in use settings ={Tunnel, }
       conn id: 5, flow_id: SW:5, sibling_flags 80000040, crypto map: Tunnel0-head-0
       sa timing: remaining key lifetime (k/sec): (4370500/42967)
       IV size: 16 bytes
       replay detection support: Y
       Status: ACTIVE(ACTIVE)

    inbound ah sas:

    inbound pcp sas:

    outbound esp sas:
     spi: 0xCEFC9AFE(3472661246)
       transform: esp-aes esp-md5-hmac ,
       in use settings ={Tunnel, }
       conn id: 6, flow_id: SW:6, sibling_flags 80000040, crypto map: Tunnel0-head-0
       sa timing: remaining key lifetime (k/sec): (4370502/42967)
       IV size: 16 bytes
       replay detection support: Y
       Status: ACTIVE(ACTIVE)

    outbound ah sas:

    outbound pcp sas:

show crypto ipsec profile
IPSEC profile IPsec_PF
       Security association lifetime: 4608000 kilobytes/43200 seconds
       Responder-Only (Y/N): N
       PFS (Y/N): N
       Transform sets={
               IPsec_TS:  { esp-aes esp-md5-hmac  } ,
       }

7. Verify the ISR state of the tunnel:

show ip interface tun0
Tunnel0 is up, line protocol is up
 Internet address is 10.255.12.2/30
 MTU is 1400 bytes
Post encapsulation features: IPSEC Post-encap output classification

show interfaces tun0
Tunnel0 is up, line protocol is up
 Internet address is 10.255.12.2/30
 Tunnel source 192.0.2.1 (GigabitEthernet0/0), destination 203.0.113.1
 Tunnel protocol/transport IPSEC/IP
 Tunnel protection via IPSec (profile "IPsec_PF")

8. Debug the P1 negotiation on the ISR to the console:

debug crypto isakmp
ISAKMP (0): received packet from 203.0.113.1 dport 500 sport 500 Global (N) NEW SA

ISAKMP: Created a peer struct for 203.0.113.1, peer port 500
ISAKMP: local port 500, remote port 500
ISAKMP:(0):atts are acceptable. Next payload is 0
ISAKMP:(0): sending packet to 203.0.113.1 my_port 500 peer_port 500 (R) MM_SA_SETUP
ISAKMP (0): received packet from 203.0.113.1 dport 500 sport 500 Global (R) MM_SA_SETUP
ISAKMP:(1001): sending packet to 203.0.113.1 my_port 500 peer_port 500 (R) MM_KEY_EXCH
ISAKMP (1001): received packet from 203.0.113.1 dport 500 sport 500 Global (R) MM_KEY_EXCH
ISAKMP:(1001):SA authentication status: authenticated
ISAKMP:(1001):SA has been authenticated with 203.0.113.1
ISAKMP:(1001):Input = IKE_MESG_INTERNAL, IKE_PHASE1_COMPLETE
ISAKMP:(1001): processing ID payload. message ID = 561157166
ISAKMP:(1001):Node 561157166, Input = IKE_MESG_FROM_PEER, IKE_QM_EXCH
ISAKMP:(1001):Node 561157166, Input = IKE_MESG_INTERNAL, IKE_GOT_SPI
ISAKMP:(1001):Node 561157166, Input = IKE_MESG_FROM_IPSEC, IPSEC_INSTALL_DONE
ISAKMP (1001): received packet from 203.0.113.1 dport 500 sport 500 Global (R) QM_IDLE      
ISAKMP:(1001):Node 561157166, Input = IKE_MESG_FROM_PEER, IKE_QM_EXCH

9. Send traffic over the tunnel from Server1 to Host1 and vice versa:

sudo traceroute -n 192.168.1.10
traceroute to 192.168.1.10 (192.168.1.10), 30 hops max, 60 byte packets

1  172.16.1.1 (172.16.1.1)  1.846 ms  1.824 ms  1.812 ms
2  10.255.12.1 (10.255.12.1)  49.158 ms  53.873 ms  55.646 ms

3  192.168.1.10 (192.168.1.10)  57.799 ms *  59.623 ms

sudo traceroute -n 172.16.1.10
traceroute to 172.16.1.10 (172.16.1.10), 30 hops max, 60 byte packets
1  192.168.1.1 (192.168.1.1)  1.726 ms  1.734 ms  1.712 ms
2  10.255.12.2 (10.255.12.2)  46.268 ms  48.562 ms  49.542 ms
3  172.16.1.10 (172.16.1.10)  56.236 ms *  55.567 ms

Related Articles


Back to Top

EdgeRouter - Hardware Offloading Explained

Intro to Networking - How to Establish a Connection Using SSH

EdgeRouter - IPsec Policy-Based Site-to-Site VPN to Cisco ISR