IPSec VPN (site to site) Configuration

Source: Internet
Author: User

The network topology is as follows:

650) this. width = 650; "title =" qq 30919175330.jpg "alt =" 175351400.jpg" src = "http://www.bkjia.com/uploads/allimg/131227/094415E52-0.jpg"/>

Description: implements the IPSecVPN channel between two gateways.

The following six steps are required for Configuration:

1. Configure routes at both ends to ensure communication between the two ends

2. Set the traffic of interest. The ACLs at both ends must be symmetric.

3. IKE1: ISAKMPSA Configuration

4. IKE2: IPSecSA Configuration

5. MAP needs to be combined with 234

6. MAP the application to the interface

The specific configuration is as follows:

Main configuration of R1

Cryptoisakmppolicy10
Encr3des
Hashmd5
Authenticationpre-share
Group2
Cryptoisakmpkey6HSKaddress172.16.1.2


Cryptoipsectransform-setHSK1esp-3desesp-md5-hmac
Modetunnel


CryptomapVPN10ipsec-isakmp
Setpeer172.16.1.2
Settransform-setHSK1
Matchaddress100


InterfaceLoopback0
Ipaddress192.168.1.1255.255.255.0


InterfaceSerial0/0
Ipaddress172.16.1.1255.255.255.0
Ipaccess-group100out
Clockrate2000000
CryptomapVPN

Iproute0.0.0.00.0.0.0Serial0/0

Access-list100permitip192.168.1.00.0.0.255192.168.2.00.0.0.255

The main configurations of R2 are as follows:

Cryptoisakmppolicy10
Encr3des
Hashmd5
Authenticationpre-share
Group2
Cryptoisakmpkey6HSKaddress172.16.1.1


Cryptoipsectransform-setHSK1esp-3desesp-md5-hmac
Modetunnel

CryptomapVPN10ipsec-isakmp
Setpeer172.16.1.1
Settransform-setHSK1
Matchaddress100

InterfaceLoopback0
Ipaddress192.168.2.1255.255.255.0

InterfaceSerial0/0
Ipaddress172.16.1.22.16255.255.0
Ipaccess-group100out
Clockrate2000000
CryptomapVPN

Iproute0.0.0.00.0.0.0Serial0/0

Access-list100permitip192.168.2.00.0.0.255192.168.1.00.0.0.255

Next, let's take a look at the test results. Open debugcryptoisakmp and debugcryptoipsec on R1 to see the phenomenon.

R1 # ping192.168.2.1source192.168.1.1

Typeescapesequencetoabort.
Sending5, 100-byteICMPEchosto192.168.2.1, timeoutis2seconds:
Packetsentwithasourceaddressof192.168.1.1

* Mar100: 59:45.839: IPSEC (sa_request ):,
(Keyeng. msg.) OUTBOUNDlocal = 172.16.1.1, remote = 172.16.1.2,
Local_proxy = 192.168.1.0/255.255.255.0/0/0 (type = 4 ),
Remote_proxy = 192.168.2.0/255.255.255.0/0/0 (type = 4 ),
Protocol = ESP, transform = NONE (Tunnel ),
Lifedur = 3600sand4608000kb,
Spi = 0x0 (0), conn_id = 0, keysize = 0, flags = 0x0
* Mar100: 59: 45.847: ISAKMP :( 0): SArequestprofileis (NULL)
* Mar100: 59: 45.847: ISAKMP: Createdapeerstructfor172.16.1.2, peerport500
* Mar100: 59: 45.847: ISAKMP: Newpeercreatedpeer = 0x646DF4E0peer_handle = 0x80000003
* Mar100: 59: 45.851: ISAKMP: Lockingpeerstruct0x646DF4E0, refcount1forisakmp_initiator
* Mar100: 59: 45.851: ISAKMP: localport500, remoteport500
* Mar100: 59: 45.851: ISAKMP: setnewnode0toQM_IDLE
* Mar100: 59: 45.855: insertsasuccessfullysa = 6490D1E0
* Mar100: 59: 45.855: ISAKMP :( 0): CannotstartAggressivemode, tryingMainmode.
* Mar100: 59: 45.855: ISAKMP. :( 0): foundpeerpre-sharedkeymatching172.16.1.2
* Mar100: 59: 45.859: ISAKMP :( 0): constructedNAT-Tvendor-07ID
* Mar100: 59: 45.859: ISAKMP :( 0): constructedNAT-Tvendor-03ID
* Mar100: 59: 45.859: ISAKMP :( 0): constructedNAT-Tvendor-02ID
* Mar100: 59: 45.859: ISAKMP :( 0): Input = IKE_MESG_FROM_IPSEC, IKE_SA_REQ_MM
* Mar100: 59: 45.863: ISAKMP :( 0): OldState = IKE_READYNewState = IKE_ I _MM1

* Mar100: 59: 45.863: ISAKMP :( 0): beginningMainModeexchange
* Mar100: 59: 45.863: ISAKMP :( 0): sendingpacketto172.16.1.2my _ port500peer_port500 (I) MM_NO_STATE
* Mar100: 59: 45.867: ISAKMP :( 0): sendinganike4104packet.
* Mar100: 59: 46.087: ISAKMP (0: 0): receivedpacketfrom172.16.1.2dport500sport500Global (I) MM_NO_STATE
* Mar100: 59: 46.091: ISAKMP :( 0): Input = IKE_M !!!!
Successrateis80percent (4/5), round-tripmin/avg/max = 40/85/188 ms
R1 # ESG_FROM_PEER, IKE_MM_EXCH
* Mar100: 59: 46.091: ISAKMP :( 0): OldState = IKE_ I _MM1NewState = IKE_ I _MM2

* Mar100: 59: 46.095: ISAKMP :( 0): processingSApayload. messageID = 0
* Mar100: 59: 46.095: ISAKMP :( 0): processingvendoridpayload
* Mar100: 59: 46.095: ISAKMP :( 0): vendorIDseemsUnity/DPDbutmajor245mismatch
* Mar100: 59: 46.099: ISAKMP (0: 0): vendorIDisNAT-Tv7
* Mar100: 59: 46.099: ISAKMP :( 0): foundpeerpre-sharedkeymatching172.16.1.2
* Mar100: 59: 46.099: ISAKMP :( 0): localpresharedkeyfound
* Mar100: 59: 46.099: ISAKMP: Scanningprofilesforxauth...
* Mar100: 59: 46.103: ISAKMP :( 0): CheckingISAKMPtransform1againstpriority10policy
* Mar100: 59: 46.103: ISAKMP: encryption3DES-CBC
* Mar100: 59: 46.103: ISAKMP: hashMD5
* Mar100: 59: 46.103: ISAKMP: defaultgroup2
* Mar100: 59: 46.103: ISAKMP: authpre-share
* Mar100: 59:46.107: ISAKMP: lifetypeinseconds
* Mar100: 59: 46.107: ISAKMP: lifeduration (VPI) of0x00x10x510x80
* Mar100: 59: 46.107: ISAKMP :( 0): attsareacceptable. Nextpayloadis0
* Mar100: 59: 46.111: ISAKMP :( 0): processingvendoridpayload
* Mar100: 59: 46.111: ISAKMP :( 0): vendorIDseemsUnity/DPDbutmajor245mismatch
* Mar100: 59: 46.111: ISAKMP (0: 0): vendorIDisNAT-Tv7
* Mar100: 59: 46.111: ISAKMP :( 0): Input = IKE_MESG_INTERNAL, IKE_PROCESS_MAIN_MODE
* Mar100: 59: 46.115: ISAKMP :( 0): OldState = IKE_ I _MM2NewState = IKE_ I _MM2

* Mar100: 59: 46.123: ISAKMP :( 0): sendingpacketto172.16.1.2my _ port500peer_port500 (I) MM_SA_SETUP
* Mar100: 59: 46.123: ISAKMP :( 0): sendinganike4104packet.
* Mar100: 59: 46.123: ISAKMP :( 0): Input = IKE_MESG_INTERNAL, IKE_PROCESS_COMPLETE
* Mar100: 59: 46.127: ISAKMP :( 0): OldState = IKE_ I _MM2NewState = IKE_ I _MM3

* Mar100: 59: 46.331: ISAKMP (0: 0): receivedpacketfrom172.16.1.2dport500sport500Global (I) MM_SA_SETUP
* Mar100: 59: 46.335: ISAKMP :( 0): Input = IKE_MESG_FROM_PEER, IKE_MM_EXCH
* Mar100: 59: 46.335: ISAKMP :( 0): OldState = IKE_ I _MM3NewState = IKE_ I _MM4

* Mar100: 59: 46.339: ISAKMP :( 0): processingKEpayload. messageID = 0
* Mar100: 59: 46.395: ISAKMP :( 0): processingNONCEpayload. messageID = 0
* Mar100: 59: 46.395: ISAKMP :( 0): foundpeerpre-sharedkeymatching172.16.1.2
* Mar100: 59: 46.399: ISAKMP :( 1002): processingvendoridpayload
* Mar100: 59: 46.399: ISAKMP :( 1002): vendorIDisUnity
* Mar100: 59: 46.403: ISAKMP :( 1002): processingvendoridpayload
* Mar100: 59: 46.403: ISAKMP :( 1002): vendorIDisDPD
* Mar100: 59: 46.403: ISAKMP :( 1002): processingvendoridpayload
* Mar100: 59: 46.403: ISAKMP :( 1002): speakingtoanotherIOSbox!
* Mar100: 59: 46.403: ISAKMP :( 1002): Input = IKE_MESG_INTERNAL, IKE_PROCESS_MAIN_MODE
* Mar100: 59: 46.403: ISAKMP :( 1002): OldState = IKE_ I _MM4NewState = IKE_ I _MM4

* Mar100: 59: 46.403: ISAKMP :( 1002): Sendinitialcontact
* Mar100: 59: 46.403: ISAKMP :( 1002): SAisdoingpre-sharedkeyauthenticationusingidtypeID_IPV4_ADDR
* Mar100: 59: 46.403: ISAKMP (): IDpayload
Next-payload: 8
Type: 1
Address: 172.16.1.1
Protocol: 17
Port: 500
Length: 12
* Mar100: 59: 46.403: ISAKMP :( 1002): Totalpayloadlength: 12
* Mar100: 59: 46.407: ISAKMP :( 1002): sendingpacketto172.16.1.2my _ port500peer_port500 (I) MM_KEY_EXCH
* Mar100: 59: 46.407: ISAKMP :( 1002): sendinganike4104packet.
* Mar100: 59: 46.407: ISAKMP :( 1002): Input = IKE_MESG_INTERNAL, IKE_PROCESS_COMPLETE
* Mar100: 59: 46.411: ISAKMP :( 1002): OldState = IKE_ I _MM4NewState = IKE_ I _MM5

* Mar100: 59: 46.547: ISAKMP (): receivedpacketfrom172.16.1.2dport500sport500Global (I) MM_KEY_EXCH
* Mar100: 59: 46.551: ISAKMP :( 1002): processingIDpayload. messageID = 0
* Mar100: 59: 46.551: ISAKMP (): IDpayload
Next-payload: 8
Type: 1
Address: 172.16.1.2
Protocol: 17
Port: 500
Length: 12
* Mar100: 59: 46.555: ISAKMP :( 0): peermatches * none * oftheprofiles
* Mar100: 59: 46.555: ISAKMP :( 1002): processingHASHpayload. messageID = 0
* Mar100: 59: 46.559: ISAKMP :( 1002): SAauthenticationstatus:
Authenticated
* Mar100: 59: 46.559: ISAKMP :( 1002): SAhasbeenauthenticatedwith172.16.1.2
* Mar100: 59: 46.559: ISAKMP: Tryingtoinsertapeer172.16.1.1/172.16.1.2/500/, andinsertedsuccessfully646DF4E0.
* Mar100: 59: 46.563: ISAKMP :( 1002): Input = IKE_MESG_FROM_PEER, IKE_MM_EXCH
* Mar100: 59: 46.563: ISAKMP :( 1002): OldState = IKE_ I _MM5NewState = IKE_ I _MM6

* Mar100: 59: 46.571: ISAKMP :( 1002): Input = IKE_MESG_INTERNAL, IKE_PROCESS_MAIN_MODE
* Mar100: 59: 46.571: ISAKMP :( 1002): OldState = IKE_ I _MM6NewState = IKE_ I _MM6

* Mar100: 59: 46.575: ISAKMP (): receivedpacketfrom172.16.1.2dport500sport500Global (I) MM_KEY_EXCH
* Mar100: 59: 46.575: ISAKMP: setnewnode1670074093toQM_IDLE
* Mar100: 59: 46.579: ISAKMP :( 1002): processingHASHpayload. messageID = 1670074093
* Mar100: 59: 46.579: ISAKMP :( 1002): processingDELETEpayload. messageID = 1670074093
* Mar100: 59: 46.583: ISAKMP :( 1002): peerdoesnotdoparanoidkeepalives.

* Mar100: 59: 46.583: ISAKMP :( 1002): deletingnode1670074093errorFALSEreason "Informational (in) state1"
* Mar100: 59:46.587: IPSEC (key_engine): gotaqueueeventwith1KMImessage (s)
* Mar100: 59: 46.587: IPSEC (key_engine_delete_sas): rec 'ddeletenotifyfromisakmp
* Mar100: 59: 46.591: ISAKMP :( 1002): Input = IKE_MESG_INTERNAL, IKE_PROCESS_COMPLETE
* Mar100: 59: 46.595: ISAKMP :( 1002): OldState = IKE_ I _MM6NewState = IKE_P1_COMPLETE

* Mar100: 59: 46.599: ISAKMP :( 1002): beginningQuickModeexchange, M-IDof-2018734306
* Mar100: 59: 46.599: ISAKMP :( 1002): QMInitiatorgetsspi
* Mar100: 59: 46.603: ISAKMP :( 1002): sendingpacketto172.16.1.2my _ port500peer_port500 (I) QM_IDLE
* Mar100: 59: 46.603: ISAKMP :( 1002): sendinganike4104packet.
* Mar100: 59: 46.607: ISAKMP :( 1002): Node-2018734306, Input = IKE_MESG_INTERNAL, IKE_INIT_QM
* Mar100: 59: 46.607: ISAKMP :( 1002): OldState = IKE_QM_READYNewState = IKE_QM_ I _QM1
* Mar100: 59: 46.607: ISAKMP :( 1002): Input = IKE_MESG_INTERNAL, IKE_PHASE1_COMPLETE
* Mar100: 59: 46.611: ISAKMP :( 1002): OldState = IKE_P1_COMPLETENewState = IKE_P1_COMPLETE

* Mar100: 59: 46.775: ISAKMP (): receivedpacketfrom172.16.1.2dport500sport500Global (I) QM_IDLE
* Mar100: 59: 46.779: ISAKMP :( 1002): processingHASHpayload. messageID =-2018734306
* Mar100: 59: 46.779: ISAKMP :( 1002): processingSApayload. messageID =-2018734306
* Mar100: 59: 46.783: ISAKMP :( 1002): CheckingIPSecproposal1
* Mar100: 59: 46.783: ISAKMP: transform1, ESP_3DES
* Mar100: 59:46.783: ISAKMP: attributesintransform:
* Mar100: 59: 46.783: ISAKMP: encapsis1 (Tunnel)
* Mar100: 59:46.783: ISAKMP: SAlifetypeinseconds
* Mar100: 59: 46.783: ISAKMP: SAlifeduration (basic) of3600
* Mar100: 59: 46.787: ISAKMP: SAlifetypeinkilobytes
* Mar100: 59: 46.787: ISAKMP: SAlifeduration (VPI) of0x00x460x500x0
* Mar100: 59: 46.787: ISAKMP: authenticatorisHMAC-MD5
* Mar100: 59: 46.791: ISAKMP :( 1002): attsareacceptable.
* Mar100: 59:46.791: IPSEC (validate_proposal_request): proposalpart #1
* Mar100: 59:46.791: IPSEC (validate_proposal_request): proposalpart #1,
(Keyeng. msg.) INBOUNDlocal = 172.16.1.1, remote = 172.16.1.2,
Local_proxy = 192.168.1.0/255.255.255.0/0/0 (type = 4 ),
Remote_proxy = 192.168.2.0/255.255.255.0/0/0 (type = 4 ),
Protocol = ESP, transform = esp-3desesp-md5-hmac (Tunnel ),
Lifedur = 0sand0kb,
Spi = 0x0 (0), conn_id = 0, keysize = 0, flags = 0x0
* Mar100: 59: 46.795: Cryptomapdb: proxy_match
Srcaddr: 192.168.1.0
Dstaddr: 192.168.2.0
Protocol: 0
Srcport: 0
Dstport: 0
* Mar100: 59: 46.799: ISAKMP :( 1002): processingNONCEpayload. messageID =-2018734306
* Mar100: 59: 46.799: ISAKMP :( 1002): processingIDpayload. messageID =-2018734306
* Mar100: 59: 46.799: ISAKMP :( 1002): processingIDpayload. messageID =-2018734306
* Mar100: 59: 46.807: ISAKMP :( 1002): CreatingIPSecSAs
* Mar100: 59: 46.807: inboundSAfrom172.16.1.2to172.16.1.1 (f/I) 0/0
(Proxy192.168.2.0to192.168.1.0)
* Mar100: 59: 46.811: hasspi0x592F35D4andconn_id0
* Mar100: 59: 46.811: lifetimeof3600seconds
* Mar100: 59: 46.811: lifetimeof4608000kilobytes
* Mar100: 59: 46.811: outboundSAfrom172.16.1.1to172.16.1.2 (f/I) 0/0
(Proxy192.168.1.0to192.168.2.0)
* Mar100: 59: 46.811: hasspi0x523FFDEandconn_id0
* Mar100: 59: 46.815: lifetimeof3600seconds
* Mar100: 59: 46.815: lifetimeof4608000kilobytes
* Mar100: 59: 46.815: ISAKMP :( 1002): sendingpacketto172.16.1.2my _ port500peer_port500 (I) QM_IDLE
* Mar100: 59: 46.819: ISAKMP :( 1002): sendinganike4104packet.
* Mar100: 59: 46.819: ISAKMP :( 1002): deletingnode-2018734306errorFALSEreason "NoError"
* Mar100: 59: 46.819: ISAKMP :( 1002): Node-2018734306, Input = IKE_MESG_FROM_PEER, IKE_QM_EXCH
* Mar100: 59: 46.823: ISAKMP :( 1002): OldState = IKE_QM_ I _QM1NewState = IKE_QM_PHASE2_COMPLETE
* Mar100: 59:46.827: IPSEC (key_engine): gotaqueueeventwith1KMImessage (s)
* Mar100: 59: 46.827: Cryptomapdb: proxy_match
Srcaddr: 192.168.1.0
Dstaddr: 192.168.2.0
Protocol: 0
Srcport: 0
Dstport: 0
* Mar100: 59: 46.831: IPSEC (crypto_ipsec_sa_find_ident_head): reconnectingwiththesameproxiesandpeer172.16.1.2
* Mar100: 59: 46.831: IPSEC (yy_db_add_ident): src192.168.1.0, dest192.168.2.0, dest_port0

* Mar100: 59: 46.831: IPSEC (create_sa): sacreated,
(Sa) sa_dest = 172.16.1.1, sa_proto = 50,
Sa_spi = 0x592F35D4 (1496266196 ),
Sa_trans = esp-3desesp-md5-hmac, sa_conn_id = 3
* Mar100: 59: 46.835: IPSEC (create_sa): sacreated,
(Sa) sa_dest = 172.16.1.2, sa_proto = 50,
Sa_spi = 0x523FFDE (86245342 ),
Sa_trans = esp-3desesp-md5-hmac, sa_conn_id = 4
* Mar100: 59: 46.835: IPSEC (update_current_outbound_sa): updatedpeer172.16.1.2currentoutboundsatoSPI523FFDE

The above shows the data transmission process.

Next let's take a look at isakmpsa and ipsecsa of R1.

R1 # showcryptoisakmpsa
IPv4CryptoISAKMPSA
Dstsrcstateconn-idslotstatus
172.16.1.2172.16.1.1QM _ IDLE10020ACTIVE

IPv6CryptoISAKMPSA

R1 # showcryptoipsecsa

Interface: Serial0/0
Cryptomaptag: VPN, localaddr172.16.1.1

Protectedvrf :( none)
Localident (addr/mask/prot/port) :( 192.168.1.0/255.255.255.0/0/0)
Remoteident (addr/mask/prot/port) :( 192.168.2.0/255.255.255.0/0/0)
Current_peer172.16.1.2port500
PERMIT, flags = {origin_is_acl ,}
# Pktsencaps: 4, # pktsencrypt: 4, # pktsdigest: 4
# Pktsdecaps: 4, # pktsdecrypt: 4, # pktsverify: 4
# Pktscompressed: 0, # pktsdecompressed: 0
# Pktsnotcompressed: 0, # pktscompr. failed: 0
# Pktsnotdecompressed: 0, # pktsdecompressfailed: 0
# Senderrors1, # recverrors0

Localcryptoendpt.: 172.16.1.1, remotecryptoendpt.: 172.16.1.2
Pathmtu1500, ipmtu1500, ipmtuidbSerial0/0
Currentoutboundspi: 0x523FFDE (86245342)

Inboundespsas:
Spi: 0x592F35D4 (1496266196)
Transform: esp-3desesp-md5-hmac,
Inusesettings = {Tunnel ,}
Connid: 3, flow_id: 3, cryptomap: VPN
Satiming: remainingkeylifetime (k/sec) :( 4542746/3345)
IVsize: 8 bytes
Replaydetectionsupport: Y
Status: ACTIVE

Inboundahsas:

Inboundpcpsas:

Outboundespsas:
Spi: 0x523FFDE (86245342)
Transform: esp-3desesp-md5-hmac,
Inusesettings = {Tunnel ,}
Connid: 4, flow_id: 4, cryptomap: VPN
Satiming: remainingkeylifetime (k/sec) :( 4542746/3343)
IVsize: 8 bytes
Replaydetectionsupport: Y
Status: ACTIVE

Outboundahsas:

Outboundpcpsas:

Now, the experiment is complete for the simple IPSec configuration. If we only want to allow host 192.168.1.1 to access 192.168.2.1 through IPSecVPN, what traffic should we allow? We need to add the following list of prevention and control measures:

R2 # showipaccess-lists101
ExtendedIPaccesslist101
10permitahphost172. 16.1.1host172.16.1.2
20permitesphost172. 16.1.1host172.16.1.2 (15 matches)
30permitudphost172. 16.1.1host172.16.1.2eqisakmp
40permitip92. 168.1.00.0.0.255192.168.2.00.0.0.255

View results

R1 # ping192.168.2.1source192.168.1.1

Typeescapesequencetoabort.
Sending5, 100-byteICMPEchosto192.168.2.1, timeoutis2seconds:
Packetsentwithasourceaddressof192.168.1.1
!!!!!
Successrateis100percent (5/5), round-tripmin/avg/max = 32/69/100 ms

This article from the "Network Technology Exploration" blog, please be sure to keep this source http://heshengkai.blog.51cto.com/5014551/1298993

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.