IKEv2 with pre-shared key authentication configuration example
Network requirements
As shown in Figure 90, configure an IKE-based IPsec tunnel between Switch A and Switch B to secure the communication between the switches.
Configure Switch A and Switch B to use the default IKEv2 proposal and the default IKEv2 policy in IKEv2 negotiation to set up IPsec SAs.
Configure the two switches to use the pre-shared key authentication method in IKEv2 negotiation.
Figure 90: Network diagram
Configuration procedures
Configure Switch A:
# Assign an IP address to VLAN-interface 1.
<SwitchA> system-view [SwitchA] interface vlan-interface 1 [SwitchA-vlan-interface1] ip address 1.1.1.1 255.255.255.0 [SwitchA-vlan-interface1] quit
# Configure IPv4 advanced ACL 3101 to identify traffic between Switch A and Switch B.
[SwitchA] acl advanced 3101 [SwitchA-acl-ipv4-adv-3101] rule 0 permit ip source 1.1.1.1 0 destination 2.2.2.2 0 [SwitchA-acl-ipv4-adv-3101] quit
# Create an IPsec transform set named tran1.
[SwitchA] ipsec transform-set tran1
# Set the packet encapsulation mode to tunnel.
[SwitchA-ipsec-transform-set-tran1] encapsulation-mode tunnel
# Use the ESP protocol for the IPsec transform set.
[SwitchA-ipsec-transform-set-tran1] protocol esp
# Specify the encryption and authentication algorithms.
[SwitchA-ipsec-transform-set-tran1] esp encryption-algorithm des-cbc [SwitchA-ipsec-transform-set-tran1] esp authentication-algorithm sha1 [SwitchA-ipsec-transform-set-tran1] quit
# Create an IKEv2 keychain named keychain1.
[SwitchA] ikev2 keychain keychain1
# Create an IKEv2 peer named peer1.
[SwitchA-ikev2-keychain-keychain1] peer peer1
# Specify peer IP address 2.2.2.2/24.
[SwitchA-ikev2-keychain-keychain1-peer-peer1] address 2.2.2.2 24
# Specify the peer ID, which is IP address 2.2.2.2.
[SwitchA-ikev2-keychain-keychain1-peer-peer1] identity address 2.2.2.2
# Specify abcde in plain text as the pre-shared key to be used with the peer at 2.2.2.2.
[SwitchA-ikev2-keychain-keychain1-peer-peer1] pre-shared-key plaintext abcde [SwitchA-ikev2-keychain-keychain1-peer-peer1] quit [SwitchA-ikev2-keychain-keychain1] quit
# Create an IKEv2 profile named profile1.
[SwitchA] ikev2 profile profile1
# Specify the local authentication method as pre-shared key.
[SwitchA-ikev2-profile-profile1] authentication-method local pre-share
# Specify the remote authentication method as pre-shared key.
[SwitchA-ikev2-profile-profile1] authentication-method remote pre-share
# Specify IKEv2 keychain keychain1.
[SwitchA-ikev2-profile-profile1] keychain keychain1
# Specify the peer ID that the IKEv2 profile matches. The peer ID is IP address 2.2.2.2/24.
[SwitchA-ikev2-profile-profile1] match remote identity address 2.2.2.2 255.255.255.0 [SwitchA-ikev2-profile-profile1] quit
# Create an IKE-based IPsec policy entry. Specify the policy name as map1 and set the sequence number to 10.
[SwitchA] ipsec policy map1 10 isakmp
# Specify remote IP address 2.2.2.2 for the IPsec tunnel.
[SwitchA-ipsec-policy-isakmp-map1-10] remote-address 2.2.2.2
# Specify ACL 3101 to identify the traffic to be protected.
[SwitchA-ipsec-policy-isakmp-map1-10] security acl 3101
# Specify IPsec transform set tran1 for the IPsec policy.
[SwitchA-ipsec-policy-isakmp-map1-10] transform-set tran1
# Specify IKEv2 profile profile1 for the IPsec policy.
[SwitchA-ipsec-policy-isakmp-map1-10] ikev2-profile profile1 [SwitchA-ipsec-policy-isakmp-map1-10] quit
# Apply IPsec policy map1 to VLAN-interface 1.
[SwitchA] interface vlan-interface 1 [SwitchA-Vlan-interface1] ipsec apply policy map1 [SwitchA-Vlan-interface1] quit
Configure Switch B:
# Assign an IP address to VLAN-interface 1.
<SwitchB> system-view [SwitchB] interface Vlan-interface1 [SwitchB-Vlan-interface1] ip address 2.2.2.2 255.255.255.0 [SwitchB-Vlan-interface1] quit
# Configure IPv4 advanced ACL 3101 to identify traffic between Switch A and Switch B.
[SwitchB] acl advanced 3101 [SwitchB-acl-ipv4-adv-3101] rule 0 permit ip source 2.2.2.2 0 destination 1.1.1.0 0 [SwitchB-acl-ipv4-adv-3101] quit
# Create an IPsec transform set named tran1.
[SwitchB] ipsec transform-set tran1
# Set the packet encapsulation mode to tunnel.
[SwitchB-ipsec-transform-set-tran1] encapsulation-mode tunnel
# Use the ESP protocol for the IPsec transform set.
[SwitchB-ipsec-transform-set-tran1] protocol esp
# Specify the encryption and authentication algorithms.
[SwitchB-ipsec-transform-set-tran1] esp encryption-algorithm des-cbc [SwitchB-ipsec-transform-set-tran1] esp authentication-algorithm sha1 [SwitchB-ipsec-transform-set-tran1] quit
# Create an IKEv2 keychain named keychain1.
[SwitchB] ikev2 keychain keychain1
# Create an IKEv2 peer named peer1.
[SwitchB-ikev2-keychain-keychain1] peer peer1
# Specify peer IP address 1.1.1.1/24.
[SwitchB-ikev2-keychain-keychain1-peer-peer1] address 1.1.1.1 24
# Specify the peer ID, which is IP address 1.1.1.1.
[SwitchB-ikev2-keychain-keychain1-peer-peer1] identity address 1.1.1.1
# Specify abcde in plain text as the pre-shared key to be used with the peer at 1.1.1.1.
[SwitchB-ikev2-keychain-keychain1-peer-peer1] pre-shared-key plaintext abcde [SwitchB-ikev2-keychain-keychain1-peer-peer1] quit [SwitchB-ikev2-keychain-keychain1] quit
# Create an IKEv2 profile named profile1.
[SwitchB] ikev2 profile profile1
# Specify the local authentication method as pre-shared key.
[SwitchB-ikev2-profile-profile1] authentication-method local pre-share
# Specify the remote authentication method as pre-shared key.
[SwitchB-ikev2-profile-profile1] authentication-method remote pre-share
# Specify IKEv2 keychain keychain1.
[SwitchB-ikev2-profile-profile1] keychain keychain1
# Specify the peer ID that the IKEv2 profile matches. The peer ID is IP address 1.1.1.1/24.
[SwitchB-ikev2-profile-profile1] match remote identity address 1.1.1.1 255.255.255.0 [SwitchB-ikev2-profile-profile1] quit
# Create an IKE-based IPsec policy entry. Specify the policy name as use1 and set the sequence number to 10.
[SwitchB] ipsec policy use1 10 isakmp
# Specify remote IP address 1.1.1.1 for the IPsec tunnel.
[SwitchB-ipsec-policy-isakmp-use1-10] remote-address 1.1.1.1
# Specify ACL 3101 to identify the traffic to be protected.
[SwitchB-ipsec-policy-isakmp-use1-10] security acl 3101
# Specify IPsec transform set tran1 for the IPsec policy.
[SwitchB-ipsec-policy-isakmp-use1-10] transform-set tran1
# Specify IKEv2 profile profile1 for the IPsec policy.
[SwitchB-ipsec-policy-isakmp-use1-10] ikev2-profile profile1 [SwitchB-ipsec-policy-isakmp-use1-10] quit
# Apply IPsec policy use1 to VLAN-interface 1.
[SwitchB] interface vlan-interface 1 [SwitchB-Vlan-interface1] ipsec apply policy use1 [SwitchB-Vlan-interface1] quit
Verifying the configuration
# Initiate a connection between Switch A and Switch B to trigger IKEv2 negotiation. After IPsec SAs are successfully negotiated by IKEv2, traffic between the two switches is IPsec protected.