- 23 Apr 2023
- 6 Minutes to read
- Print
- DarkLight
- PDF
Global WAN Solution with Cloudflare MagicWAN
- Updated on 23 Apr 2023
- 6 Minutes to read
- Print
- DarkLight
- PDF
Overview
Cloudflare MagicWAN enables customers to easly replace global MPLS or other dedicated connections, using Cloudflare's dedicated global backbone. The solution requires a local IPSec router (compatible with the Cloudflare MagicWAN solution).
ZPE Nodegrid appliances are tested and validated with the Cloudflare MagicWAN solution. The combination of Cloudflare and Nodegrid SR appliances provide customers with an easyily deployed global solution, fully managed with the ZPE Cloud SaaS system).
The customer builds IPSec tunnels from each location to the closest Cloudflare POP. From there, traffic is transported on the Cloudflare backbone.
First, talk with your Cloudflare representative on the deployment of Cloudflare Magic WAN. The provided onboarding document includes IPs for the IPsec/GRE connection to access your Cloudflare account.
NOTE: This guide describes connection of one site to Cloudflare with MagicWAN. Use the same process to connect multiple locations to the same MagicWAN instance.
Prerequisites
Before begining with the implementation, the customer should have the following information ready.
Setting | Comment |
---|---|
Nodegrid Public IP Address | Static Public IP |
Nodegrid Internal IP Address | Internal network accessable through Cloudflare WAN |
Tunnel Peer to Peer Address | /31 network for peer to peer connection |
Cloudflare Multicast Address | IP addresses provided by Cloudflare |
Cloudflare Routes | Routes to be routed to Cloudflare MagicWAN |
User ID | Created by Cloudflare after tunnel configuration |
Cloudflare MagicWAN Configuration
Connect to your Cloudflare account and go to: Magic WAN
Click on Configure for Manage Magic WAN Configuration
Click Create to create a IPSec Tunnel for Site A. Provide the following details
Setting | Value | Comment |
---|---|---|
Tunnel Name | NAME | Tunnel Name |
Description | DESCRIPTION | Tunnel Description |
Interface Address | INTERNAL TUNNEL IP | Internal tunnel IP address, must be part of a /31 network. The entered IP address, is assigned to the Cloudflare tunnel side |
Customer endpoint | PUBLIC NODEGRID IP ADDRESS | Static IP address assigned to Nodegrid |
Cloudflare endpoint | PUBLIC CLOUDFLARE IP ADDRESSS | This IP address is provided by Cloudflare during the account setup |
Pre-shared key | PRE-SHARED KEY | Provide a pre-shared secret |
- After the tunnel is added, go to Static Routes.
- Click +CREATE.
- Provide the following details :
Setting | Value | Comment |
---|---|---|
Description | DESCRIPTION | Route Description |
Prefix | ROUTE PREFIX | Provide a routing prefix for Site A |
Tunnel/Next hop | TUNNEL NEXT HOP | Select the tunnel next hop, which was created for Site A |
Priority | 100 | Provide the route priority, default is 100 |
Region code | ALL Regions | Select the region to which the routes should be pushed, by default select all |
- Deployments of tunnels and routes take a few minutes to complete within the Cloudflare enviorment.
- Copy the User ID from the Tunnel information page,
Should have the format ipsec@f5407d8db1a542b196c59f6d04ba8bd1.123456789.ipsec.cloudflare.com
Nodegrid MagicWAN Configuration
To configure MagicWAN on a Nodegrid device requires the following steps:
- Prepare the Nodegrid for IPSec configuration with a VTI interface.
- Create a IPSec IKE Profile.
- Create a IPSec tunnel for MagicWAN.
- Create static routes (if needed).
Prepare Nodegrid
- Login to the Nodegrid WebUI as admin user
- Go to Network :: Settings.
- Enable and confirm the following settings
Setting | Value | Comment |
---|---|---|
Enable IPv4 IP Forward | Enabled | Enables routing stack for IPv4 traffic |
Enable IPv6 IP Forward | Enabled | Enables routing stack for IPv6 traffic |
Reverse Path Filtering | Loose Mode | This must be set to Loose Mode (Recommended) or Disabled to avoid IPSec specific issues |
Create a MagicWAN IKE Profile
- Go to Network :: VPN :: IPSec.
- In the IPSec section, scroll to Global
- Select Enable Virtual Tunnel Interface.
- Click Save.
- In the IPSec section, go to IKE Profile.
- Click ADD
- Provide the following settings for the Cloudflare MagicWAN profile
Setting | Value | Comment |
---|---|---|
Profile Name | CloudflareMagicWAN | Profile Name |
IKE Version | IKEv2 | |
Phase 1 - Encryption | AES-CBC256 | |
Phase 1 - Authentication | SHA256 | |
Phase 1 - Diffie-Hellman Group | Group14 (MODP2048) | |
Phase 1 - Lifetime | 3600 | |
Phase 2 - Authentication Protocol | ESP | |
Phase 2 - Encryption | AES-CBC256 | |
Phase 2 - Authentication | SHA256 | |
Phase 2 - PFS Group | Group14 (MODP2048) | |
Phase 2 - Lifetime | 28800 | |
Advanced Settings - Enable Dead Peer Detection | Enabled | |
Advanced Settings - Number of Retries | 5 | |
Advanced Settings - Interval | 2 | |
Advanced Settings - Action | restart | |
Advanced Settings - MTU | 1400 |
- Click on Save
Create IPSec tunnel
- In the IPSec section navigate to Tunnel
- Click ADD.
- Create the tunnel and provide the following details
Setting | Value | Comment |
---|---|---|
Name | MagicWAN | Name for the Tunnel |
Initiate Tunnel | Start | Define when the tunnel should start. Recommended is on start up of teh Nodegrid (Start) |
IKE Profile | CloudflareMagicWAN | Select the newly create profile |
Authentication Method - Pre-Shared Key | PRE-SHARED KEY | Provide the same pre-shared key which was used during the Cloudflare configuration |
Left ID | USER ID | Use the User ID from the Cloudflare Tunnel configuration which has the format ipsec@f5407d8db1a542b196c59f6d04ba8bd1.123456789.ipsec.cloudflare.com |
Left Address | INTERFACE | Select the interface which responds to the Nodegrid Public IP address, i.e. %eth0 |
Left Source IP Address | NODEGRID TUNNEL IP ADDRESS | |
Left Subnet | Local Network | Local Network, which will be reachable through the tunnel, this must include the IP address range used for for Left Source IP |
Right ID | CLOUDFLARE PUBLIC IP ADDRESS | |
Right Address | CLOUDFLARE PUBLIC IP ADDRESS* | |
Right Source IP Address | CLOUDFLARE TUNNEL IP ADDRESS | |
Right Subnet | TUNNEL NETWORKS | Networks which will be reachable through the tunnel |
Enable Virtual Tunnel Interface | Enabled | |
Mark | -1 | use the default value of -1 |
Interface | cloudflare | tunnel interface name |
Automatically create VTI routes | Enabled | Enable this option to create routes based on the provided subnet information |
Share VTI with other connections | Enabled |
- Click Save (saves and activates the IPSec Tunnel).
- To confirm the IPSec tunnel state, on the Tunnel page, check the connection state.
Note: It can be required to enforce the MSS size for the MagicWAN tunnel. Follow the below steps to enforce the MSS and make it persistent.
- Navigate to the root shell
- navigate to /etc/scripts/auditing
- create a new file called enforce-mss.sh' with
vi enforce-mss-clamping.sh
- enter the following text into the file
#!/bin/bash iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1380
- save the changes with :wq!
- make the file executable with
chmod +x enforce-mss.sh
- Asign the script now to either the system Start Up event (101) or the IPSec Start Event (162)
- In the WebUI, Navigate to Audit :: Events : Event List
- Click on the Event ID 162
- Select the script from the drop down list for the field Action Script
- Click on Save
- Restart the IPSec Tunnel to make teh change effective or directly excute the script from the root shell with
/etc/scripts/auditing/enforce-mss.sh
Nodegrid Configuration via import_settings
An alternative process is to aply a predefined configuration with the import_settings command.
- Open a console connection as a admin user.
- Run the command
import_settings
. - Paste in the prepared configuration.
- Press CTRL+D to apply the configuartion.
In the below example replace the following values:
- secret
- left_id
- left_address
- left_source_ip_address
- left_subnet
- right_id
- right_address
- right_source_ip_address
- right_subnet
Here is the full Nodegrid configuration:
/settings/network_settings enable_ipv4_ip_forward=yes
/settings/network_settings enable_ipv6_ip_forward=no
/settings/network_settings reverse_path_filtering=loose_mode
/settings/ipsec/ike_profile/CloudflareMagicWAN profile_name=CloudflareMagicWAN
/settings/ipsec/ike_profile/CloudflareMagicWAN ike_version=ikev2
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_1_mode=main
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_1_encryption=aes-cbc256
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_1_authentication=sha256
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_1_diffie-hellman_group=group_14
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_1_lifetime=3600
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_2_authentication_protocol=esp
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_2_encryption=aes_cbc256
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_2_authentication=sha2_256
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_2_pfs_group=group_14
/settings/ipsec/ike_profile/CloudflareMagicWAN phase_2_lifetime=28800
/settings/ipsec/ike_profile/CloudflareMagicWAN enable_dead_peer_detection=yes
/settings/ipsec/ike_profile/CloudflareMagicWAN dead_peer_detection_number_of_retries=5
/settings/ipsec/ike_profile/CloudflareMagicWAN dead_peer_detection_interval=2
/settings/ipsec/ike_profile/CloudflareMagicWAN dead_peer_detection_action=restart
/settings/ipsec/ike_profile/CloudflareMagicWAN mtu=1400
/settings/ipsec/tunnel/Cloudflare name=Cloudflare
/settings/ipsec/tunnel/Cloudflare initiate_tunnel=ignore
/settings/ipsec/tunnel/Cloudflare ike_profile=CloudflareMagicWAN
/settings/ipsec/tunnel/Cloudflare authentication_method=pre-shared_key
/settings/ipsec/tunnel/Cloudflare secret=********
/settings/ipsec/tunnel/Cloudflare left_id=Y.Y.Y.Y
/settings/ipsec/tunnel/Cloudflare left_address=%eth0
/settings/ipsec/tunnel/Cloudflare left_source_ip_address=192.168.50.1/31
/settings/ipsec/tunnel/Cloudflare left_subnet=192.168.50.1/31, 172.0.0.0/24
/settings/ipsec/tunnel/Cloudflare right_id=Z.Z.Z.Z
/settings/ipsec/tunnel/Cloudflare right_address=Z.Z.Z.Z
/settings/ipsec/tunnel/Cloudflare right_source_ip_address=192.168.105.0
/settings/ipsec/tunnel/Cloudflare right_subnet=192.168.50.0/31,10.0.0.0/8
/settings/ipsec/tunnel/Cloudflare enable_monitoring=no
/settings/ipsec/tunnel/Cloudflare enable_virtual_tunnel_interface=yes
/settings/ipsec/tunnel/Cloudflare vti_mark=-1
/settings/ipsec/tunnel/Cloudflare vti_interface=cloudflare
/settings/ipsec/tunnel/Cloudflare automatically_create_vti_routes=yes
/settings/ipsec/tunnel/Cloudflare share_vti_with_other_connections=yes