This topic describes how to use SSL-VPN to connect a client that runs Linux, macOS,
Windows, or Android to a virtual private cloud (VPC).
Background information
The scenario in the following figure is used as an example to describe how to use
SSL-VPN to connect a client that runs Linux, macOS, Windows, or Android to a VPC.
The private CIDR block of the client does not overlap with the private CIDR block
of the VPC.
The client can access the Internet.
You have learned about the security group rules that apply to the Elastic Compute
Service (ECS) instances in the VPC. Make sure that the security group rules allow
the client to access the ECS instances. For more information, see Query security group rules and Add a security group rule.
On the VPN Gateways page, click Create VPN Gateway.
On the VPN Gateway page, set the following parameters and click Buy Now to complete the payment:
Parameter
Description
Name
Enter a name for the VPN gateway.
Region
Select the region where you want to create the VPN gateway.
Note Make sure that the VPN gateway and the VPC are deployed in the same region.
VPC
Select the VPC to be connected.
Specify VSwitch
Select whether to associate the VPN gateway with a specified vSwitch. In this example,
No is selected.
Maximum Bandwidth
Select a maximum bandwidth value for the VPN gateway. Unit: Mbit/s.
The bandwidth is used for data transfer over the Internet.
Traffic
By default, the VPN gateway uses the pay-by-data-transfer metering method. For more
information, see Pay-as-you-go.
IPsec-VPN
Specify whether to enable the IPsec-VPN feature. In this example, Disable is selected.
SSL-VPN
Specify whether to enable the SSL-VPN feature for the VPN gateway. In this example,
Enable is selected.
SSL Connections
Select the number of clients to be connected.
Note The SSL Connections parameter is available only after you enable the SSL-VPN feature.
Duration
By default, the VPN gateway is billed on an hourly basis.
Return to the VPN Gateways page to view the VPN gateway that you created.
The VPN gateway that you created is in the Preparing state. The VPN gateway changes to the Normal state after about 1 to 5 minutes. After the VPN gateway changes to the Normal state, the VPN gateway is ready for use.
Step 2: Create an SSL server
In the left-side navigation pane, choose Interconnections > VPN > SSL Servers.
In the top navigation bar, select the region where you want to create an SSL server.
Note Make sure that the SSL server and the VPN gateway that you created are deployed in
the same region.
On the SSL Server page, click Create SSL Server.
In the Create SSL Server panel, set the following parameters and click OK:
Name: Enter a name for the SSL server.
VPN Gateway: Select the VPN gateway that you created.
Local Network: Enter the CIDR block of the VPC to which you want to connect.
Click Add Local Network to add more CIDR blocks. You can add the CIDR block of a VPC, a vSwitch, or an on-premises
network.
Client Subnet: Enter the CIDR block that the client uses to connect to the SSL server.
Notice
The subnet mask of the client CIDR block must be 16 to 29 bits in length.
Make sure that the local CIDR block and the client CIDR block do not overlap with
each other.
We recommend that you use the 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, or one of
their subnets as the client CIDR block. If you want to specify a public CIDR block
as the client CIDR block, you must specify the public CIDR block as the user CIDR
block of the VPC. This way, the VPC can access the public CIDR block. For more information
about user CIDR blocks, see What is a user CIDR block? and How do I configure a user CIDR block?.
Advanced Configuration: The default settings are used in this example.
Decompress the SSL client certificate package that you downloaded and copy the SSL
client certificate to the OpenVPN\confi directory.
In this example, the certificate is copied to C:\Program Files\OpenVPN\config. You must copy the certificate to the directory where the OpenVPN client is installed.
Start the OpenVPN client and click Connect to establish a connection.
Use Tunnelblick to connect a client that runs macOS
The following section describes how to use Tunnelblick to establish an SSL-VPN connection
between a client that runs macOS and a VPN gateway.
Run the following command to install the OpenVPN client:
brew install openvpn
Copy the SSL client certificate package that you downloaded in Step 3 to the configuration directory of the OpenVPN client and decompress the package.
Back up all configuration files in the /usr/local/etc/openvpn folder.
Run the following command to delete the configuration files of the OpenVPN client:
rm /usr/local/etc/openvpn/*
Run the following command to copy the SSL client certificate package that you downloaded
to the configuration directory of OpenVPN:
cp cert_location /usr/local/etc/openvpn/
In the preceding command, replace cert_location with the directory to which the SSL client certificate package is downloaded in Step 3. For example: /Users/example/Downloads/certs6.zip.
Run the following command to decompress the package:
cd /usr/local/etc/openvpn/
unzip /usr/local/etc/openvpn/certs6.zip
Run the following command to establish an SSL-VPN connection:
In this example, a client that runs Android 9.0 and an OpenVPN client of version 3.0.5
are used.
Transfer the SSL client certificate package that you downloaded in Step 3 to the client that runs Android and decompress the package.
Note
If your client that runs Android does not have an application to decompress the package,
you can decompress the certificate on your computer and then transfer the decompressed
files to the client.
Make sure that the decompressed files belong to the same folder. The following figure
shows an example.
Open the OpenVPN client, import the config.ovpn file, and add an SSL-VPN connection.
Step
Description
①
Select OVPN Profile.
②
Find the config.ovpn file.
③
Click IMPORT to import the config.ovpn file.
④
The system reads information from the config.ovpn file and displays the public IP address of the VPN gateway to be connected. Click
ADD to add an SSL-VPN connection.
Turn on the switch to establish an SSL-VPN connection.
Step 5: Test the network connectivity
To test the network connectivity, access an ECS instance in the VPC from a client.
FAQ
After I use OpenVPN to establish an SSL-VPN connection on a client that runs macOS,
how do I close the connection?
Open the CLI on the client that runs macOS.
Run the following command to search for the OpenVPN process and record the process
number:
ps aux | grep openvpn
Run the following command to close the OpenVPN process:
kill -9 <Process number>
How do I use OpenVPN to establish an SSL-VPN connection on a client that runs macOS
and uses an M1 chip?
If you use a client that runs macOS and uses an M1 chip, we recommend that you use
Tunnelblick to establish an SSL-VPN connection. For more information, see Use Tunnelblick to connect a client that runs macOS.