In the previous lesson, you saw what IPsec protects and how IKE negotiates the tunnel in two phases.
In this lesson, you build that tunnel between two sites and verify each phase on the router.Before you can configure IPsec, the underlay must be working.
This lab uses the same topology and addressing as the GRE lesson.
Figure 1 - IPsec lab topology
The routing is also identical: static routes on ISP1 and ISP2, and default routes on R1 and R2.

Figure 2 - Routing configuration on the IPsec topology
Here is a quick recap of the routing configuration:
ISP1# conf t Enter configuration commands, one per line. End with CNTL/Z. ISP1(config)# ip route 203.0.113.8 255.255.255.252 203.0.113.6
Figure 3 - ISP2 static routing
ISP2# conf t Enter configuration commands, one per line. End with CNTL/Z. ISP2(config)# ip route 203.0.113.0 255.255.255.252 203.0.113.5
Figure 4 - Default route configuration
R1(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.2R2(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.9At this point, R1 and R2 can reach each other's WAN interfaces through the ISP network.
Your underlay is ready. Now you can build the IPsec tunnel on top of it.Answer the question below
Why must R1 and R2 have WAN reachability before configuring IPsec?
Now that your routing is in place, you can configure the IPsec site-to-site VPN.

Figure 5 - IPsec site-to-site lab topology
The configuration follows a strict workflow with five steps.
Follow them in order.
Figure 6 – IPsec configuration workflow
The five steps are:
Define interesting traffic (ACL)
Configure IKE Phase 1 (ISAKMP policy + pre-shared key)
Configure IKE Phase 2 (transform set)
Create the crypto map (ties everything together)
Apply the crypto map to the WAN interface
Step 1 — Define Interesting Traffic
First, you need to tell your router which traffic should be encrypted. This is called interesting traffic.
You define it with an extended ACL that matches the source and destination subnets.Any traffic matching this ACL triggers IPsec encryption.
Traffic that does not match travels in cleartext.
Figure 7 – ACL Configuration Step
R1:
R1(config)# access-list 100 permit 10.10.10.0 0.0.0.255 10.20.20.0 0.0.0.255R2:
R2(config)# access-list 100 permit 10.20.20.0 0.0.0.255 10.10.10.0 0.0.0.255Notice that the ACLs are mirrored. On R1, the source is 10.10.10.0/24 and the destination is 10.20.20.0/24. On R2, it is the opposite.
This is critical. If the ACLs do not mirror each other, the IPsec tunnel will not form for that traffic.
Step 2 — Configure IKE Phase 1
Next, you configure the secure management channel between R1 and R2.
You need two things: the ISAKMP policy (encryption, hash, authentication, DH group, lifetime) and the pre-shared key.
Figure 8 – IKE Phase 1 configuration step
R1:
R1(config)# crypto isakmp policy 1 R1(config-isakmp)# encryption aes R1(config-isakmp)# hash sha R1(config-isakmp)# authentication pre-share R1(config-isakmp)# group 14 R1(config-isakmp)# lifetime 86400 R1(config-isakmp)# exit R1(config)# crypto isakmp key cisco address 203.0.113.10R2:
R2(config)# crypto isakmp policy 1 R2(config-isakmp)# encryption aes R2(config-isakmp)# hash sha R2(config-isakmp)# authentication pre-share R2(config-isakmp)# group 14 R2(config-isakmp)# lifetime 86400 R2(config-isakmp)# exit R2(config)# crypto isakmp key cisco address 203.0.113.1Let's break down what you just configured:
crypto isakmp policy 1: Creates ISAKMP policy with priority 1 (lower number = higher priority).encryption aes: Uses AES for encrypting IKE messages.hash sha: Uses SHA for integrity checking.authentication pre-share: Authenticates the peer using a pre-shared key.group 14: Uses Diffie-Hellman group 14 (2048-bit) for key exchange.lifetime 86400: The ISAKMP SA expires after 86400 seconds (24 hours).crypto isakmp key cisco address 203.0.113.10: Sets the pre-shared key to "cisco" for the peer at 203.0.113.10.
Both sides must have matching ISAKMP policy parameters. The pre-shared key must also be identical on both peers.
Step 3 — Configure IKE Phase 2 (Transform Set)
Now you define how your actual user traffic will be encrypted.
This is done through a transform set.
Figure 9 – IKE Phase 2 configuration step
R1:
R1(config)# crypto ipsec transform-set IPSEC-SET esp-aes esp-sha-hmac R1(cfg-crypto-trans)# mode tunnel R1(cfg-crypto-trans)# exitR2:
R2(config)# crypto ipsec transform-set IPSEC-SET esp-aes esp-sha-hmac R2(cfg-crypto-trans)# mode tunnel R2(cfg-crypto-trans)# exitcrypto ipsec transform-set IPSEC-SET: Creates a transform set named "IPSEC-SET".esp-aes: Uses AES for payload encryption (ESP).esp-sha-hmac: Uses SHA HMAC for payload integrity (ESP).mode tunnel: Encapsulates the entire original IP packet inside a new IP header. This is the default and the most common mode for site-to-site VPNs.
Your encryption method is now defined. Next, you need to tie everything together.
Step 4 — Create the Crypto Map
You now have your ACL, your ISAKMP policy, and your transform set.
The crypto map is what ties all of them together into a single policy.
Figure 10 – Crypto map configuration step
R1:
R1(config)# crypto map VPN-MAP 1 ipsec-isakmp R1(config-crypto-map)# set peer 203.0.113.10 R1(config-crypto-map)# set transform-set IPSEC-SET R1(config-crypto-map)# match address 100 R1(config-crypto-map)# exitR2:
R2(config)# crypto map VPN-MAP 1 ipsec-isakmp R2(config-crypto-map)# set peer 203.0.113.1 R2(config-crypto-map)# set transform-set IPSEC-SET R2(config-crypto-map)# match address 100 R2(config-crypto-map)# exitcrypto map VPN-MAP 1 ipsec-isakmp: Creates crypto map entry "VPN-MAP" with sequence number 1, using IKE for key management.set peer: Specifies the remote IPsec peer's WAN IP address.set transform-set IPSEC-SET: Links your transform set from Step 3.match address 100: Links your ACL from Step 1.
Step 5 — Apply Crypto Map to Interface
Last step. You apply the crypto map to the outbound WAN interface on each router.
This is what activates IPsec.
Figure 11 – Crypto map applied to interface
R1:
R1(config)# interface g0/0 R1(config-if)# crypto map VPN-MAP %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON %LINEPROTO-5-UPDOWN: Line protocol on Interface NVI0, changed state to upR2:
R2(config)# interface g0/0 R2(config-if)# crypto map VPN-MAP %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON %LINEPROTO-5-UPDOWN: Line protocol on Interface NVI0, changed state to upThe ISAKMP is ON message confirms that IKE is now active on this interface.
Your router is ready to negotiate IPsec tunnels with any peer defined in the crypto map.Answer the question below
What is the name of the component that ties together the peer, transform set, and ACL?
Your configuration is complete, but how do you know it actually works? You need to verify that the IPsec tunnel is established and encrypting traffic.
The tunnel is on-demand: it only forms when interesting traffic triggers it.

Figure 12 – IPsec Connectivity Test
Trigger the Tunnel with a Ping
Start by sending a ping from R1's LAN interface to R2's LAN interface. This traffic matches your ACL 100 and triggers the IKE negotiation.
R1:
R1# ping 10.20.20.1 source 10.10.10.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.20.20.1, timeout is 2 seconds: Packet sent with a source address of 10.10.10.1 .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 6/10/19 msThe first packet is lost (the
.before the!!!!). This is normal.The first packet triggers the IKE negotiation, which takes a few hundred milliseconds. By the time the negotiation completes, the first ICMP echo has already timed out. The remaining four packets succeed because the tunnel is now established.
Send a second ping to confirm full connectivity:
R1# ping 10.20.20.1 source 10.10.10.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.20.20.1, timeout is 2 seconds: Packet sent with a source address of 10.10.10.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 9/10/11 ms100% success. Your tunnel is up and all traffic flows through it.
Now let's look at the show commands to confirm what is happening behind the scenes.Verify IKE Phase 1 — show crypto isakmp sa
Run this command to check your ISAKMP Security Association (Phase 1 tunnel).
R1# show crypto isakmp sa IPv4 Crypto ISAKMP SA dst src state conn-id status 203.0.113.10 203.0.113.1 QM_IDLE 1001 ACTIVE IPv6 Crypto ISAKMP SALook at the output:
dst / src: The two peers' WAN IP addresses.
state: QM_IDLE is the expected state. It means Phase 1 is complete and the SA is idle, waiting for Phase 2 quick mode (QM) requests. If you see
MM_NO_STATEorAG_NO_STATE, the negotiation failed.status: ACTIVE: The ISAKMP SA is operational.
Verify IPsec Phase 2 — show crypto ipsec sa
This command gives you the full picture of your IPsec Security Associations (Phase 2) with detailed encryption statistics.
R1# show crypto ipsec sa interface: GigabitEthernet0/0 Crypto map tag: VPN-MAP, local addr 203.0.113.1 protected vrf: (none) local ident (addr/mask/prot/port): (10.10.10.0/255.255.255.0/0/0) remote ident (addr/mask/prot/port): (10.20.20.0/255.255.255.0/0/0) current_peer 203.0.113.10 port 500 PERMIT, flags={origin_is_acl,} #pkts encaps: 9, #pkts encrypt: 9, #pkts digest: 9 #pkts decaps: 9, #pkts decrypt: 9, #pkts verify: 9 #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 0The key lines to check:
local ident / remote ident — Confirms which subnets are protected (10.10.10.0/24 ↔ 10.20.20.0/24). These match your ACL 100.
#pkts encaps / encrypt / digest — The number of packets encrypted and sent. If these counters increment, traffic is flowing through the tunnel.
#pkts decaps / decrypt / verify — The number of packets received and decrypted. These should roughly match the encaps counters.
Verify Crypto Map — show crypto map
Run this command to see your full crypto map configuration as applied to the interface.
R1# show crypto map Interfaces using crypto map NiStTeSt1: Crypto Map IPv4 "VPN-MAP" 1 ipsec-isakmp Peer = 203.0.113.10 Extended IP access list 100 access-list 100 permit ip 10.10.10.0 0.0.0.255 10.20.20.0 0.0.0.255 Current peer: 203.0.113.10 Security association lifetime: 4608000 kilobytes/3600 seconds Responder-Only (Y/N): N PFS (Y/N): N Mixed-mode : Disabled Transform sets={ IPSEC-SET: { esp-aes esp-sha-hmac }, } Interfaces using crypto map VPN-MAP: GigabitEthernet0/0You can see that VPN-MAP is applied to GigabitEthernet0/0, using your transform set IPSEC-SET, matching your ACL 100, with peer 203.0.113.10.
The SA lifetime shows 4608000 kilobytes or 3600 seconds (1 hour). Whichever is reached first triggers rekeying.
Verify ACL Matches — show access-lists
R1# show access-lists Extended IP access list 100 10 permit ip 10.10.10.0 0.0.0.255 10.20.20.0 0.0.0.255 (11 matches)The (11 matches) counter confirms that traffic has matched your ACL and was sent through the IPsec tunnel. If this counter stays at 0, no interesting traffic is being generated.
Verification from R2
Now run the same checks from R2 to confirm both sides are operational.
Start with a ping:R2# ping 10.10.10.1 source 10.20.20.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.10.10.1, timeout is 2 seconds: Packet sent with a source address of 10.20.20.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/8/15 ms100% success from R2 as well. Now check the ISAKMP SA:
R2# show crypto isakmp sa IPv4 Crypto ISAKMP SA dst src state conn-id status 203.0.113.10 203.0.113.1 QM_IDLE 1001 ACTIVE IPv6 Crypto ISAKMP SAYou should see the same QM_IDLE state. Now verify the IPsec SA and check that the packet counters are incrementing:
R2# show crypto ipsec sa interface: GigabitEthernet0/0 Crypto map tag: VPN-MAP, local addr 203.0.113.10 protected vrf: (none) local ident (addr/mask/prot/port): (10.20.20.0/255.255.255.0/0/0) remote ident (addr/mask/prot/port): (10.10.10.0/255.255.255.0/0/0) current_peer 203.0.113.1 port 500 PERMIT, flags={origin_is_acl,} #pkts encaps: 14, #pkts encrypt: 14, #pkts digest: 14 #pkts decaps: 14, #pkts decrypt: 14, #pkts verify: 14 #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 0Finally, confirm the crypto map and ACL matches:
R2# show crypto map Interfaces using crypto map NiStTeSt1: Crypto Map IPv4 "VPN-MAP" 1 ipsec-isakmp Peer = 203.0.113.1 Extended IP access list 100 access-list 100 permit ip 10.20.20.0 0.0.0.255 10.10.10.0 0.0.0.255 Current peer: 203.0.113.1 Security association lifetime: 4608000 kilobytes/3600 seconds Responder-Only (Y/N): N PFS (Y/N): N Mixed-mode : Disabled Transform sets={ IPSEC-SET: { esp-aes esp-sha-hmac }, } Interfaces using crypto map VPN-MAP: GigabitEthernet0/0R2# show access-lists Extended IP access list 100 10 permit ip 10.20.20.0 0.0.0.255 10.10.10.0 0.0.0.255 (14 matches)Both sides confirm matching SAs, incrementing packet counters, and zero errors.
Your IPsec site-to-site VPN is fully operational.Next, you combine this tunnel with GRE so it can carry routing protocols across the ISP.
Answer the question below
What state should the ISAKMP SA show when Phase 1 is successfully established?
Answer the question below
Which SPI do the ESP packets that R2 sends to R1 carry?