This tutorial shows you how to connect Alibaba Cloud infrastructure to Cloudflare WAN (formerly Magic WAN) through IPsec tunnels. For more information regarding Alibaba Cloud technology, refer to Alibaba's documentation ↗.
- Log in to your Alibaba Cloud account.
- Go to VPC > VPN Gateways, and select Create VPC to create a new Virtual Private Cloud (VPC).
- Give your VPC a descriptive name. For example,
Cloudflare-Magic-WAN. - Choose the Region that aligns with where your servers are located.
- In IPv4 CIDR block, choose from one of the recommended Internet Protocol (IP) blocks in Classless Inter-Domain Routing (CIDR) notation. For example,
192.168.20.0/24. Take note of the IP block you choose, as you will need it to create a static route in Cloudflare WAN.
- Still in your Alibaba Cloud account, go to VPC > VPN Gateway, and select Create VPN Gateway.
- Give your VPN Gateway a descriptive name. For example,
VPN-Gateway-Magic-WAN. - In Region, choose the server that is best for your geographic region. For example, US (Silicon Valley).
- For Gateway Type, choose Standard.
- In Network Type, choose Public.
- For Tunnels, select Single-tunnel.
- In the VPC dropdown menu, choose the name of the VPC you created before for Cloudflare WAN. For example,
Cloudflare-Magic-WAN. - In the VSwitch drop-down menu, choose the VSwitch you created previously. For example,
VSwitch-CF. - For options such as Maximum Bandwidth, Traffic, and Duration, select the options that best suit your use case.
- In IPsec-VPN, select Enable.
- For SSL-VPN, select Disable.
- When you are finished configuring your VPN gateway, return to the main VPN Gateway window.
- Select the VPN gateway you have just created, and then select Destination-based Routing.
- Select Add Route Entry, and enter the subnets needed to reach the required destinations. For example, you can add a default route to send all traffic through your IPsec tunnel.
- When you are finished, return to the main window.
- Select Publish > OK to publish the route.
- Go to VPC > Customer Gateways > Create Customer Gateway.
- Create a customer gateway with one of the Cloudflare anycast IP addresses assigned to your account, available in Leased IPs ↗. This typically starts with
162.xx.xx.xx. - Now, go to VPC > IPsec Connections > Create IPsec Connection.
- Create an IPsec connection with the following settings:
- Name: give it a descriptive name, like
CF-Magic-WAN-IPsec. - Associate Resource: VPN Gateway.
- VPN Gateway: From the dropdown menu, choose the VPN gateway you created previously. In our example,
VPN-Gateway-Magic-WAN. - Customer Gateway: Select the customer gateway you created above for Cloudflare WAN.
- Routing Mode: Destination Routing Mode.
- Effective Immediately: Yes.
- Pre-Shared Key: This is the pre-shared key (PSK) you will have to use in the Cloudflare WAN IPsec tunnel. If you do not specify one here, the Alibaba system will generate a random pre-shared key for you.
- Name: give it a descriptive name, like
- Go to Advanced Settings, and expand the Encryption Configuration settings.
- In IKE Configurations, select the following settings to configure the IPsec connection. These settings have to match the supported configuration parameters for Cloudflare WAN IPsec tunnels:
- Version: ikev2
- Negotiation Mode: main
- Encryption Algorithm: aes256
- Authentication Algorithm: sha256
- DH Group: group20
- Localid: This is the customer endpoint. These are generally IP addresses provided by your ISP. For example,
47.xxx.xxx.xxx.
- Follow the Add tunnels instructions to create the required IPsec tunnels with the following options:
- Tunnel name: Give your tunnel a descriptive name, like
Alibaba. - Interface address: Choose from the subnet in your Alibaba Cloud configuration. For example, if your Alibaba default configuration is
169.xx.xx.1/30, you might want to choose169.xx.xx.2/30for your Cloudflare WAN side of the IPsec tunnel. - Customer endpoint: This is the IP address you entered for Localid in Alibaba's IPsec connection. For example,
47.xxx.xxx.xxx. - Cloudflare endpoint: Enter the same anycast IP address provided by Cloudflare you have entered for Alibaba's Customer Gateway. Typically starts with
162.xx.xx.xx. - Pre-shared key: Select Use my own pre-shared key, and enter the PSK key from your Alibaba Cloud IPsec tunnel.
- Replay protection: Enabled.
- Tunnel name: Give your tunnel a descriptive name, like
- Select Add tunnels when you are done.
- Follow the Configure static routes instructions to create a static route.
- In Prefix, enter the IP CIDR you used to create your virtual private cloud in the Alibaba Cloud interface. In our example we used
192.168.20.0/24.