Basic IPSec VPN Lab for Dynamips
As I mentioned at the end of the Basic Frame Relay Lab for Dynamips, the next lab will cover how to set up an IPSec site-to-site VPN between R2 and R3 to encrypt our data in transit.
I adhere to the KISS principle so to avoid adding more virtual routers to the topology to act as hosts, we’re going to use the loopback 0 interfaces on R2 and R3 that we configured last time as our end IP addresses for testing. If you missed the last lab, go ahead and get it set up and verify full connectivity between the routers and then continue on.
Okay, so we have R1, R2, and R3 up and running, EIGRP adjacencies established, and full routing between all interfaces. Let’s jump right in to setting up our IPSec VPN!
Our first step is to configure the ISAKMP policies on each router. In this lab, we’ll use a pre-shared key for authentication, 128-bit AES for our encryption algorithm, Diffie-Helman group 2 (1024-bit modulus) and SHA hashing:
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#crypto isakmp policy 10
R2(config-isakmp)#authentication pre-share
R2(config-isakmp)#encryption aes 128
R2(config-isakmp)#group 2
R2(config-isakmp)#hash sha
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#crypto isakmp policy 10
R3(config-isakmp)#authentication pre-share
R3(config-isakmp)#encryption aes 128
R3(config-isakmp)#group 2
R3(config-isakmp)#hash sha
Our next step is to configure the pre-shared key that we wish to use. Note that we must use the same key (”SECRET_KEY”) on both ends of the VPN:
R2(config-isakmp)#crypto isakmp key 0 SECRET_KEY address 172.16.123.3 no-xauth
R3(config-isakmp)#crypto isakmp key 0 SECRET_KEY address 172.16.123.2 no-xauth
With our ISAKMP policy and pre-shared key configured, we can now define our transform set:
R2(config)#crypto ipsec transform-set R2_R3_TRANSFORM esp-aes 128 esp-sha-hmac
R3(config)#crypto ipsec transform-set R3_R2_TRANSFORM esp-aes 128 esp-sha-hmac
Our next step will be to tell the routers what traffic should be encrypted. We do this with an access list. For this lab, we’ll tell R2 that any traffic from 172.16.2.2 destined for 172.16.3.3 should be encrypted. On R3, we’ll do just the opposite: any traffic from 172.16.3.3 destined for 172.16.2.2 should be encrypted. Note that the access lists on each end must be a “mirror image” of each other for the VPN to properly function:
R2(cfg-crypto-trans)#ip access-list extended ENCRYPTED_TRAFFIC
R2(config-ext-nacl)#permit ip host 172.16.2.2 host 172.16.3.3
R3(cfg-crypto-trans)#ip access-list extended ENCRYPTED_TRAFFIC
R3(config-ext-nacl)#permit ip host 172.16.3.3 host 172.16.2.2
Awesome, almost done! We have two steps left. We still need to configure our crypto maps and then apply them to the appropriate interfaces. Once that’s done, we should have connectivity. Let’s set up the crypto maps:
R2(config-ext-nacl)#crypto map R2_R3_MAP 10 ipsec-isakmp
% NOTE: This new crypto map will remain disabled until a peer
and a valid access list have been configured.
R2(config-crypto-map)#set peer 172.16.123.3
R2(config-crypto-map)#match address ENCRYPTED_TRAFFIC
R2(config-crypto-map)#set transform-set R2_R3_TRANSFORM
R3(config-ext-nacl)#crypto map R3_R2_MAP 10 ipsec-isakmp
% NOTE: This new crypto map will remain disabled until a peer
and a valid access list have been configured.
R3(config-crypto-map)#set peer 172.16.123.2
R3(config-crypto-map)#match address ENCRYPTED_TRAFFIC
R3(config-crypto-map)#set transform-set R3_R2_TRANSFORM
Now we just apply the crypto maps to the appropriate interfaces (serial 0/0, in both cases here) and we should be good to go:
R2(config-crypto-map)#interface serial 0/0
R2(config-if)#crypto map R2_R3_MAP
R2(config-if)#
*Mar 1 00:13:02.011: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON
R3(config-crypto-map)#interface serial 0/0
R3(config-if)#crypto map R3_R2_MAP
R3(config-if)#
*Mar 1 00:14:31.447: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON
With everything now in place, we should be able to send a ping from 172.16.2.2 (R2’s loopback0 interface) to 172.16.3.3 (R3’s loopback0 interface) and get a response. Note that, because of our access list, we must specify 172.16.2.2 as the source IP address of the pings:
R2#ping 172.16.3.3 source 172.16.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.3.3, timeout is 2 seconds:
Packet sent with a source address of 172.16.2.2
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 32/71/112 ms
We can verify that the VPN is up and running with the use of “show crypto isakmp sa” and “show crypto ipsec sa”:
R2#show crypto isakmp sa
dst src state conn-id slot status
172.16.123.3 172.16.123.2 QM_IDLE 1 0 ACTIVE
R2#show crypto ipsec sa
interface: Serial0/0
Crypto map tag: R2_R3_MAP, local addr 172.16.123.2
protected vrf: (none)
local ident (addr/mask/prot/port): (172.16.2.2/255.255.255.255/0/0)
remote ident (addr/mask/prot/port): (172.16.3.3/255.255.255.255/0/0)
current_peer 172.16.123.3 port 500
PERMIT, flags={origin_is_acl,ipsec_sa_request_sent}
#pkts encaps: 4, #pkts encrypt: 4, #pkts digest: 4
#pkts decaps: 4, #pkts decrypt: 4, #pkts verify: 4
#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.123.2, remote crypto endpt.: 172.16.123.3
path mtu 1500, ip mtu 1500
current outbound spi: 0x995FE2D0(2573198032)
inbound esp sas:
spi: 0x18DD060C(417138188)
transform: esp-aes esp-sha-hmac ,
in use settings ={Tunnel, }
conn id: 2002, flow_id: SW:2, crypto map: R2_R3_MAP
sa timing: remaining key lifetime (k/sec): (4439841/3591)
IV size: 16 bytes
replay detection support: Y
Status: ACTIVE
inbound ah sas:
inbound pcp sas:
outbound esp sas:
spi: 0x995FE2D0(2573198032)
transform: esp-aes esp-sha-hmac ,
in use settings ={Tunnel, }
conn id: 2001, flow_id: SW:1, crypto map: R2_R3_MAP
sa timing: remaining key lifetime (k/sec): (4439841/3544)
IV size: 16 bytes
replay detection support: Y
Status: ACTIVE
outbound ah sas:
outbound pcp sas:
Prior to running that ping, we could’ve done the following in Dynagen to start a packet capture:
=> capture R1 s0/0 ipsec.cap FR
We would then have ended up with a packet capture file we could load up into Wireshark. If you had done that, you would see something like this (click for larger image):
From the packet capture, we can see the ISAKMP negotiation, the IPSec negotation, as well as the ESP (encrypted) traffic between R2 and R3. Because we did the capturing on R1’s serial 0/0 interface, we actually see each packet listed twice in the capture. If we had captured at R2 or R3’s serial 0/0 interface, we would only see them once.
I hope you enjoyed the lab and learned something from it. Let me know if there’s something specific you’d like to see in future labs or video demos!
Related Posts:







angel:
this was a great lab. I was wandering how to crfeat a lab like on the net since i dont have real equipment.
thanks very much for making this topic easy to understand without the proper equipment. angel
February 28, 2009, 7:04 pmangel:
This was a create help. i was having dificulty understading the topic. I m using cbt nugget and some cisco books. I was looking for something like this to create real labs.
this have been a great help. i hope that in the future, you guys keep help new future cisco tech to understand this types of topic.
angel
February 28, 2009, 7:08 pmGNS3 Topology: Basic IPSec VPN Over Frame-Relay Lab | GNS3 Labs :: Cisco Router Simulator Network Topologies:
[...] over at EvilRouters.net created 2 cool labs. 1 was a basic frame-relay lab and the other was adding IPSec VPN to the lab. He gave some great details and outlined the configuration - step by step. I compiled [...]
March 14, 2009, 7:17 amJeremy:
@angel
I’m glad you found it useful; that is why I posted it. I’m always looking for ideas on things to post, so if there’s anything you’d like to see here, just let me know!
-Jeremy
March 20, 2009, 6:17 pmJeff:
What router models did you perform this lab with? I have configured my lab the same way and it doesn’t work. I cannot get any debug info at all!! I have verified over and over my configuration and made sure isakmp was enabled.
Any ideas?
March 30, 2009, 6:49 pmjlgaddis:
Hi Jeff,
It’s been a few months since I originally posted this, so I don’t recall exactly. It most likely would have been with 3640s and one of the crypto images. Taking a look at what’s on my local TFTP server, if I was a betting man I’d wager it was “c3640-jk9o3s-mz.124-16.bin”. If you’re not sure if your image supports IPSec (not all of them do), check the Feature Navigator (http://cisco.com/go/fn) to verify.
Feel free to post your details (what router model, output of “show version”, etc.) and I’ll see if I can be of any help.
-Jeremy
March 31, 2009, 4:58 am