Made4it

GRE + IPSec tunnel between Cisco IOS and Huawei NE40

In this post we will discuss a very common (and little documented) scenario, which is to use a GRE tunnel secured with IPSec between a Cisco IOS ASR1002 router and a Huawei NE40 router.

The topology for this example is described below. It has been kept simple so that we can discuss the details of GRE+IPSEC without getting into the rest of the network.

In this setup, we have a Cisco router with the public IP address 198.51.100.2 and a Huawei NE40 router with the public IP address 203.0.113.66. Both are connected to the Internet and are connected to each other. We need to establish a GRE tunnel between the routers and secure it using IPSec in tunnel mode. The tunnel’s address space is 172.31.31.0/30.

In the next lines below we will talk about GRE and IPSec. The objective is not to completely detail these protocols, but to give an overview and, mainly, a basis for the rest of the article. Don’t be hasty, there is very relevant information in there.

GRE

Generic Routing Encapsulation (GRE) is a tunneling protocol that can encapsulate a variety of network protocols (eg ATM, IPX, IPv6 and even IPv4) within IPv4 packets. These packets can then be transmitted over common IPv4 networks (eg Internet).

Some use cases for GRE:
connecting internal networks that are not directly connected to each other
connecting isolated IPv6 networks via IPv4 networks
establishing communication between headquarters and branches over the Internet
mitigation links
using VPNs when routing protocols are required


IPSEC

IPSec is a security framework developed by the IETF that seeks to solve security problems that the IPv4 protocol failed to address, such as encryption, data integrity, source validation, and anti-replay.
IPSec is actually not a single protocol, but a combination of protocols and algorithms. The main ones are IKEv1, IKEv2, ESP and AH.

IPSec is widely used in VPNs, both remote-access and site-to-site.

In the life cycle of a tunnel, we have 5 well-defined stages:

  1. Definition of interesting traffic
    Interesting traffic is the trigger that causes the tunnel to be established. When the router or firewall detects interesting traffic, it initiates the next steps in the IPSec negotiation.
    Interesting traffic is usually configured in the form of ACLs, or traffic policies.

  2. IKE Phase 1
    In Phase 1, the protocol establishes a secure communication channel with the remote peer. Once this secure channel is established, Phase 2 message exchanges are permitted.
    It is in phase 1 that peers are protected, authenticated, and ISAKMP policies are compared (and need to match). There are two modes, main and aggressive.

    Terms you will see about phase 1: ike, isakmp, DH group, pre-shared-key, integrity, isakmp policy

  3. IKE Phase 2
    In this phase, with the secure tunnel already established in Phase 1, we can negotiate what are called IPSec SAs, which are essentially dynamically negotiated “contracts” specifying the type of traffic that will be protected by the IPSec tunnel. An example might be “I will protect traffic from the 192.168.1.0/24 network when the destination is 192.168.2.0/24 using encryption algorithm X and authentication algorithm Y,” and the remote peer establishes the rule in the opposite direction.

    Another function of phase 2 is to maintain SAs, as well as expire keys and sessions if some parameter is reached (e.g. expire SAs and trade new ones every x hours, or every N kilobytes).

    Terms we will see about phase 2: ipsec, ipsec sa, crypto acl, transform set, mode tunnel, authentication, encryption, ipsec policy


  4. Data Transfer This phase involves the data transfer itself. Once the relevant traffic arrives at the router and phases 1 and 2 are complete, the packets are sent in accordance with the agreements established in the IPSec SAs and transmitted to the remote peer.


  5. Tunnel Termination The tunnel is terminated manually, or when an IPSec parameter expires or reaches its limit. In this case, all keys are discarded, the agreements are terminated, and if traffic needs to be routed, a new IPSec tunnel must be established.

For more details on GRE and IPSEC, please refer to the references cited at the end of the article.

The GRE and IPSEC configurations agreed upon by the parties

The example below is how VPN information is agreed upon. These are usually forms that are filled out with information about the tunnel.

VPN Device

Site A VPN Device

Site B VPN Device

VPN Peer IP Address *

198.51.100.2

203.0.113.66

Device *

Cisco ASR 1004

Huawei NE40-M2K

Version *

V3.0.6

Tunnel Properties

Site A VPN Device

Site B VPN Device

Phase 1

Authentication Method

APasswordWellS3gur@

APasswordWellS3gur@

IKE version

IKEv2

IKEv2

Diffie-Hellman Group

group 14

group 14

Encryption Algorithm *

AES 256

AES 256

Hashing Algorithm *

SHA-1

SHA-1

Main or Aggressive Mode *

Main mode

Main mode

SA Lifetime * (for renegotiation) with no kbytes rekeying

86400 seconds

86400 seconds

Phase 2

Encapsulation * (ESP or AH)

ESP

ESP

Encryption Algorithm *

AES 256

AES 256

Authentication Algorithm *

SHA-1

SHA-1

Perfect Forward Secrecy for rekeying *

Disabled

Disabled

Diffie-Hellman Group *

group 14

group 14

SA Lifetime * (for renegotiation) ) with no kbytes rekeying

3600 seconds

3600 seconds

GRE

Addressing

172.31.31.1/30

172.31.31.2/30

Keepalives

Disabled

Disabled

MTU

1400

1400

Adjust MSS

1360

1360

Important License/Module Information

Check with the manufacturer of your equipment to see if some kind of service card, or license is not required.

In the case of the equipment in this lab, the NE40-M2K router did not need an additional physical module, just the IPSec license. On the Cisco router no license was needed either, because its IOS was already in ADVIPSERVICES-K9 (which contains the entire basis for Ipsec).

*Helpful information*: if you want to run IKEv1, on the Huawei router you need a software module for IKEv1 (which you get from the Huawei vendor).

Cisco IOS XE Configurations

So let’s configure the Cisco router to establish the VPN. I won’t go into detail about the physical interfaces, only about the VPN. At the end of the article there is a block with the relevant conf of them.

Phase 1 settings, according to the table above:

Everything above applies to Phase 1. So when you’re troubleshooting issues, and the problem is related to this phase, you’ll already know where to look 🙂.

Now setting up phase 2:

Too simple on Cisco! We will now combine the two phases into one profile:

Creating the GRE tunnel and adding IPSec protection:

Huawei Settings

So let’s configure the Huawei router to establish the VPN. As with Cisco, I won’t go into detail about the physical interfaces, only the VPN. At the end of the article there is a block with the relevant conf of them.

The configuration on the Huawei router is a bit more complex, as it creates one tunnel for the GRE protocol, and one tunnel for IPSec. Also, we want to use the same IP for both tunnels, so a VRF is needed. 😮

Creating the service instance to use the VPN (only applicable on NE40):

Upgrading the new VRF (vpn-instance):

Creating the two Loopback interfaces with the same IP (VRF magic). The looback with the IPSec tunnel will be in the public routing table, while the one with the GRE tunnel will be in the VPNA table.

Now we come to IPSec.

The interesting traffic ACL defines the traffic that will be protected by IPSec. In this case then, we will have GRE traffic between the IPs of site A and site B. Note that I only communicate in one direction – the direction of the router protecting its traffic).

The above ACL can be read like this:

“Protect GRE protocol data coming from VRF vpna between source 203.0.113.66 and destination 198.51.100.2”

Now let’s move on to setting up Phase 1 (remember that Cisco actually starts with this phase—it’s much simpler). In the middle of this phase, there are some VPN-Instance binding configurations, due to the VRF that was created.

Everything above applies to Phase 1. So when you’re troubleshooting issues, and the problem is related to this phase, you’ll already know where to look 🙂.

We move on to phase 2:

We will now combine the two phases into one profile:

Creating GRE and IPSEC tunnels. Let’s not get confused:

Tunnel 900 – is a GRE tunnel, operating inside the vpna.

Tunnel 10 – is an IPSec tunnel, operating on the global table

The idea at Huawei is to have an IPSec tunnel running on the outside and a second GRE tunnel on the inside, with one encapsulated within the other. But the funny thing is that the GRE tunnel runs outside the VRF, and the IPSec tunnel runs inside it. It’s a bit of a mess, isn’t it?

Then tunnel900 which is the GRE (and which receives the IPs from /30) uses a destination that goes inside the VPNA. And inside the VPNA the destination is reached by the IPSec tunnel. Also note that the IPsec policy has been associated with tunnel 10, using the profile that was created.

Last but not least, a route that is somewhat complex in itself: within the VPNA instance, I specify that to reach the remote peer, I use the newly created IPSec interface, with the peer itself as the next hop.

And so we set up the Huawei router. Let’s see if it has gone up now.

Operation Validation

In the tunnel validation process, we must always remember that each phase and stage depends on the complete establishment of the other, so there is no point in wanting to have connectivity if phase 1 has not yet established communication.

On both routers, we will validate in sequence:

  • connectivity
  • phase1
  • phase2
  • GRE connectivity
  • interface status

Let’s go to the tests.

Cisco Check

Validating connectivity via ICMP ping

Checking that IKEv2 has established in Phase 1:

When nothing appears in the output, or it is not ready, it means that some of the parameters in Phase 1 did not match. Check on both sides if they agree.

We continue validation in Phase 2:

In the output above, we see that the routers have switched the “interesting traffic” contract. Each side has committed to protecting one direction of GRE communication.

Following on still in Phase 2, there are some very important counters that refer to packets sent/received/encrypted/verified. It is in the output of the “show crypto ipsec sa” command. Let’s take a look at them.

When these counters are not incrementing, or still incrementing failures, it is because some Phase 2 configuration is not matching.

A good example would be that only the encaps/encrypt counter is incremented, while the decaps/decrypt is reset to zero. This is going to be an interesting traffic ACL problem that is diverging on both sides. Or a communication blockage in the transport network, or other factors that we won’t go into here. If you need help, be sure to contact us.

Finally, let’s validate the connectivity itself! But now inside the tunnel already protected!

And the tunnel interface is up, and functional:

Huawei Check

To validate operation on the Huawei NE40 router, the approach is the same as for the Cisco.

Validating connectivity via ICMP ping (remember to use loopback source)

Checking that IKEv2 has established in Phase 1:

When nothing appears in the output, or it is not in ready (RD), it means that some of the Phase 1 parameters did not match. Check on both sides if they agree.

We continue validation in Phase 2:

Finally, let’s validate the connectivity itself by checking the traffic counters! But now inside the tunnel already protected!

And the tunnel interface is up, and functional:

With this we arrive at the established and functioning tunnel between the Cisco IOS XE router and the Huawei NE40!

Complete Cisco Configuration

Huawei Complete Configuration

Authors

Rafael Ganascim

Julian Eble

References

[1] Overview of the GRE. NE40E-M2 Huawei. https://support.huawei.com/hedex/hdx.do?docid=EDOC1100277532&id=EN-US_CONCEPT_0172355906&ui=1

Made4it arises to meet the needs of the market, which has been demanding more and more personalized solutions.