IKE-based IPsec tunnel for IPv4 packets configuration example

Network requirements

As shown in Figure 85, configure an IPsec tunnel between Switch A and Switch B to protect data flows between Switch A and Switch B. Configure the tunnel to use the security protocol ESP, the encryption algorithm AES-CBC-128, and the authentication algorithm HMAC-SHA1-96.

Figure 85: Network diagram

Configuration procedure

  • Configure Switch A:

  • # Assign an IP address to VLAN-interface 1.

    <SwitchA> system-view
    [SwitchA] interface vlan-interface 1
    [SwitchA-Vlan-interface1] ip address 2.2.2.1 255.255.255.0
    [SwitchA-Vlan-interface1] quit
    

    # Define an ACL to identify data flows from Switch A to Switch B.

    [SwitchA] acl number 3101
    [SwitchA-acl-adv-3101] rule 0 permit ip source 2.2.2.1 0 destination 2.2.3.1 0
    [SwitchA-acl-adv-3101] rule 5 permit ip source 2.2.3.1 0 destination 2.2.2.1 0
    [SwitchA-acl-adv-3101] quit
    

    # Create an IPsec transform set named tran1.

    [SwitchA] ipsec transform-set tran1
    

    # Specify the encapsulation mode as tunnel.

    [SwitchA-ipsec-transform-set-tran1] encapsulation-mode tunnel
    

    # Specify the security protocol as ESP.

    [SwitchA-ipsec-transform-set-tran1] transform esp
    

    # Specify the algorithms for the transform set.

    [SwitchA-ipsec-transform-set-tran1] esp encryption-algorithm aes-cbc-128
    [SwitchA-ipsec-transform-set-tran1] esp authentication-algorithm sha1
    [SwitchA-ipsec-transform-set-tran1] quit
    

    # Configure the IKE peer.

    [SwitchA] ike peer peer
    [SwitchA-ike-peer-peer] pre-shared-key Ab12<><>
    [SwitchA-ike-peer-peer] remote-address 2.2.3.1
    [SwitchA-ike-peer-peer] quit
    

    # Create an IKE-based IPsec policy for IPsec SA negotiation.

    [SwitchA] ipsec policy map1 10 isakmp
    

    # Apply the IPsec transform set.

    [SwitchA-ipsec-policy-isakmp-map1-10] transform-set tran1
    

    # Apply the ACL.

    [SwitchA-ipsec-policy-isakmp-map1-10] security acl 3101
    

    # Apply the IKE peer.

    [SwitchA-ipsec-policy-isakmp-map1-10] ike-peer peer
    [SwitchA-ipsec-policy-isakmp-map1-10] quit
    

    # Apply the IPsec policy group to VLAN-interface 1.

    [SwitchA] interface vlan-interface 1
    [SwitchA-Vlan-interface1] ipsec policy map1
    
  • Configure Switch B:

  • # Assign an IP address to VLAN-interface 1.

    <SwitchB> system-view
    [SwitchB] interface vlan-interface 1
    [SwitchB-Vlan-interface1] ip address 2.2.3.1 255.255.255.0
    [SwitchB-Vlan-interface1] quit
    

    # Define an ACL to identify data flows from Switch B to Switch A.

    [SwitchB] acl number 3101
    [SwitchB-acl-adv-3101] rule 0 permit ip source 2.2.3.1 0 destination 2.2.2.1 0
    [SwitchB-acl-adv-3101] rule 5 permit ip source 2.2.2.1 0 destination 2.2.3.1 0
    [SwitchB-acl-adv-3101] quit
    

    # Create an IPsec transform set named tran1.

    [SwitchB] ipsec transform-set tran1
    

    # Specify the encapsulation mode as tunnel.

    [SwitchB-ipsec-transform-set-tran1] encapsulation-mode tunnel
    

    # Specify the security protocol as ESP.

    [SwitchB-ipsec-transform-set-tran1] transform esp
    

    # Specify the algorithms for the transform set.

    [SwitchB-ipsec-transform-set-tran1] esp encryption-algorithm aes-cbc-128
    [SwitchB-ipsec-transform-set-tran1] esp authentication-algorithm sha1
    [SwitchB-ipsec-transform-set-tran1] quit
    

    # Configure the IKE peer.

    [SwitchB] ike peer peer
    [SwitchB-ike-peer-peer] pre-shared-key Ab12<><>
    [SwitchB-ike-peer-peer] remote-address 2.2.2.1
    [SwitchB-ike-peer-peer] quit
    

    # Create an IKE-based IPsec policy for IPsec SA negotiation.

    [SwitchB] ipsec policy use1 10 isakmp
    

    # Apply the ACL.

    [SwitchB-ipsec-policy-isakmp-use1-10] security acl 3101
    

    # Apply the IPsec transform set.

    [SwitchB-ipsec-policy-isakmp-use1-10] transform-set tran1
    

    # Apply the IKE peer.

    [SwitchB-ipsec-policy-isakmp-use1-10] ike-peer peer
    [SwitchB-ipsec-policy-isakmp-use1-10] quit
    

    # Apply the IPsec policy group to VLAN-interface 1.

    [SwitchB] interface vlan-interface 1
    [SwitchB-Vlan-interface1] ipsec policy use1
    

    Verifying the configuration

    After the previous configuration, send traffic from Switch B to Switch A. Switch A starts IKE negotiation with Switch B when receiving the first packet. If IKE negotiation is successful and SAs are set up, the traffic between the two switches will be IPsec protected.