NETWORKSTIP Networking CCNA,Centos,Ubuntu,Sql,

Made By Muhammad Nafees

Breaking

Tuesday, 21 November 2017

Configure Site to Site IPSec VPN Tunnel in Cisco IOS Router

IPSec VPN Intruduction

Using a VPN and the Internet is cheap, secure and also very scalable. 
It‟s easier to get an internet connection through DSL or cable somewhere than a leased line.
There are a number of different protocols that we can use to create a VPN. 
A very common method to build a VPN is IPSEC. 
IPSEC is not a protocol but a framework for security on the network layer. 
It was created because there is no security on the network layer (layer 3). 
The IP protocol has nothing that will authenticate or encrypt our IP packets or check their integrity.
When you configure IPSEC you can choose between multiple protocols, for example for
encryption you can select DES, 3DES or AES.
For integrity you can choose between MD5 and SHA and for authentication you also have multiple options like password authentication or certificates.
IPSEC is very flexible, throughout the years newer and better protocols have been added
and older protocols might be removed in the future. 
When you use your VPN client on your laptop or setup a VPN between two routers or firewalls, you are probably using IPSEC.

1st of All enable security feature  SecurityK9

(config)#license boot module c2900 technology-package securityk9
#reload
# sh version 

Technology Package License Information for Module:'c2900'
 ----------------------------------------------------------------------------------------------
 Technology              Technology-package                 Technology-package
                                  Current             Type                 Next   reboot
 -------------------------------------------------------------------------------------------
 ipbase                       ipbasek9           Permanent        ipbasek9
security                     securityk9         Evaluation       securityk9
uc                              None                 None                None
data                           None                 None                None

Configure Site to Site IPSec VPN Tunnel in Cisco IOS Router

Diagram below shows our simple scenario. The two sites have static public IP address as shown in the diagram. R1 is configured with 70.54.241.1/24 and R2 is configured with 199.88.212.2/24 IP address. As of now, both routers have very basic setup like, IP addresses, NAT Overload, default route, hostnames, SSH logins, etc.


There are two phases in IPSec configuration called Phase 1 and Phase 2.
Let’s start the configuration with R1.
Before you start configuring the IPSec VPN, make sure both routers can reach each other.
I have already verified that both routers can ping each other so let’s start the VPN configuration.

Step 1. Configuring IPSec Phase 1 (ISAKMP Policy)

R1(config)#crypto isakmp policy 5 
R1(config-isakmp)#hash sha
R1(config-isakmp)#authentication pre-share
R1(config-isakmp)#group 2
R1(config-isakmp)#lifetime 86400
R1(config-isakmp)#encryption 3des
R1(config-isakmp)#exit
R1(config)#crypto isakmp key cisco@123 address 199.88.212.2

Here is the details of each commands used above,
  • crypto isakmp policy 5 – This command creates ISAKMP policy number 5. You can create multiple policies, for example 7, 8, 9 with different configuration. Routers participating in Phase 1 negotiation tries to match a ISAKMP policy matching against the list of policies one by one. If any policy is matched, the IPSec negotiation moves to Phase 2.
  • hash sha – SHA algorithm will be used.
  • authentication pre-share – Authentication method is pre-shared key.
  • group 2 – Diffie-Hellman group to be used is group 2.
  • encryption 3des – 3DES encryption algorithm will be used for Phase 1.
  • lifetime 86400 – Specifies when the crypto policy’s security associations expire and must
    be reestablished. Phase 1 lifetime is 86400 seconds.
  • crypto isakmp key cisco@123 address 199.88.212.2 – The Phase 1 password is cisco@123 and remote peer IP address is 199.88.212.2.The pre-share key must be the same on each peer router. The crypto isakmp shared key also specifies the terminating ends of the IPSEC tunnel.

Step 2. Configuring IPSec Phase 2 (Transform Set)

R1(config)#crypto ipsec transform-set MY-SET esp-aes 128 esp-md5-hmac
R1(cfg-crypto-trans)#crypto ipsec security-association lifetime seconds 3600
 
Here is the detail of command used above,
  • crypto ipsec transform-set MY-SET – Creates transform-set called MY-SET
  • esp-aes – AES encryption method and ESP IPSec protocol will be used.
  • esp-md5-hmac – MD5 hashing algorithm will be used.
  • crypto ipsec security-association lifetime seconds – This is the amount to time that the phase 2 session exists before re-negotiation.
Step 3. Configuring Extended ACL for interesting traffic.

R1(config)#ip access-list extended VPN-TRAFFIC
R1(config-ext-nacl)#permit ip  192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
 
This ACL defines the interesting traffic that needs to go through the VPN tunnel.
Here, traffic originating from 192.168.1.0 network to 192.168.2.0 network will go via VPN tunnel. This ACL will be used in Step 4 in Crypto Map.

Step 4. Configure Crypto Map.
R1(config)#crypto map IPSEC-SITE-TO-SITE-VPN 10 ipsec-isakmp 
% NOTE: This new crypto map will remain disabled until a peer and a valid access 
list have been configured. 
 
R1(config-crypto-map)#match address VPN-TRAFFIC
R1(config-crypto-map)#set peer 199.88.212.2
R1(config-crypto-map)#set transform-set MY-SET
 
Here is the detail of command used above,
  • crypto map IPSEC-STE-TO-STE-VPN 10 ipsec-isakmp – Creates new crypto map with sequence number 10. 
  • You can create more sequence numbers with same crypto map name if you have multiple sites.
  • match address VPN-TRAFFIC – Its matches interesting traffic from ACL named VPN-TRAFFIC.
  • set peer 199.88.212.2 – This is public IP address of R2.
  • set transform-set MY-SET – This links the transform-set in this crypto map configuration.

Step 5. Apply Crypto Map to outgoing interface of R1.

R1(config)#int fa0/0
R1(config-if)#crypto map IPSEC-SITE-TO-SITE-VPN
 
*Mar  1 05:43:51.114: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON
 
Step 6. Exclude VPN traffic from NAT Overload.

R1(config)#ip access-list extended 101
R1(config-ext-nacl)#deny ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255 
R1(config-ext-nacl)#permit ip 192.168.1.0 0.0.0.255 any 
R1(config-ext-nacl)#exit
R1(config)#ip nat inside source list 101 interface FastEthernet0/0 overload 

Above ACL 101 will exclude interesting traffic from NAT.

Now, repeat same steps in R2.

Step 1. Configuring IPSec Phase 1 (ISAKMP Policy)

R2(config)#crypto isakmp policy 5
R2(config-isakmp)#hash sha
R2(config-isakmp)#authentication pre-share
R2(config-isakmp)#group 2
R2(config-isakmp)#lifetime 86400
R2(config-isakmp)#encryption 3des
R2(config-isakmp)#exit
R2(config)#crypto isakmp key cisco@123 address 70.54.241.2

 Step 2. Configuring IPSec Phase 2 (Transform Set)

R2(config)#crypto ipsec transform-set MY-SET esp-aes 128 esp-md5-hmac
R2(cfg-crypto-trans)#crypto ipsec security-association lifetime seconds 3600 
 
Step 3. Configuring Extended ACL for interesting traffic.

R2(config)#ip access-list extended VPN-TRAFFIC
R2(config-ext-nacl)#permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255 

Step 4. Configure Crypto Map.

R2(config)#crypto map IPSEC-SITE-TO-SITE-VPN 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)#match address VPN-TRAFFIC
R2(config-crypto-map)#set peer 70.54.241.2
R2(config-crypto-map)#set transform-set MY-SET

Step 5. Apply Crypto Map to outgoing interface

R2(config)#int fa0/1
R2(config-if)#crypto map IPSEC-SITE-TO-SITE-VPN 
 
*Mar 1 19:16:14.231: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON
 
Step 6. Exclude VPN traffic from NAT Overload.

R1(config)#ip access-list extended 101 
R1(config-ext-nacl)#deny ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255 
R1(config-ext-nacl)#permit ip 192.168.2.0 0.0.0.255 any 
R1(config-ext-nacl)#exit 
R1(config)#ip nat inside source list 101 interface FastEthernet0/1 overload

Verification and testing.

To test the VPN connection let’s ping from R1 to PC2.
 
R1#ping 192.168.2.1 source 192.168.1.254

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.254
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/54/56 ms
 
As you can see, the ping from R1 to PC2 is successful. 
Don’t forget to ping from inside IP address while testing the VPN tunnel from the router. 
You can also ping from PC1 to PC2.

To verify the IPSec Phase 1 connection, type show crypto isakmp sa as shown below.

R1#show crypto isakmp sa
dst             src             state          conn-id slot status
70.54.241.2     199.88.212.2    QM_IDLE              1    0 ACTIVE
 
To verify IPSec Phase 2 connection, type show crypto ipsec sa as shown below.
 
R1#show crypto ipsec sa

interface: FastEthernet0/0
    Crypto map tag: IPSEC-SITE-TO-SITE-VPN, local addr 70.54.241.2

   protected vrf: (none)
   local  ident (addr/mask/prot/port): (192.168.1.0/255.255.255.0/0/0)
   remote ident (addr/mask/prot/port): (192.168.2.0/255.255.255.0/0/0)
   current_peer 199.88.212.2 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 16, #recv errors 0

     local crypto endpt.: 70.54.241.2, remote crypto endpt.: 199.88.212.2
     path mtu 1500, ip mtu 1500, ip mtu idb FastEthernet0/0
     current outbound spi: 0xD41CAB1(222415537)

     inbound esp sas:
      spi: 0x9530FB4E(2503015246)
        transform: esp-aes esp-md5-hmac , 

You can also view active IPSec sessions using show crypto session command as shown below.

R1#show crypto session
Crypto session current status

Interface: FastEthernet0/0
Session status: UP-ACTIVE
Peer: 199.88.212.2 port 500
  IKE SA: local 70.54.241.2/500 remote 199.88.212.2/500 Active
  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

 

 

 
 

1 comment:

  1. Configure Site To Site Ipsec Vpn Tunnel In Cisco Ios Router - Networkstip Networking Ccna,Centos,Ubuntu,Sql, >>>>> Download Now

    >>>>> Download Full

    Configure Site To Site Ipsec Vpn Tunnel In Cisco Ios Router - Networkstip Networking Ccna,Centos,Ubuntu,Sql, >>>>> Download LINK

    >>>>> Download Now

    Configure Site To Site Ipsec Vpn Tunnel In Cisco Ios Router - Networkstip Networking Ccna,Centos,Ubuntu,Sql, >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete