VK Cloud logo

Setting up a VPN tunnel using SDN Neutron

VK Cloud allows you to establish network connectivity between on-premises infrastructure and a VK Cloud virtual network with SDN Neutron using a VPN tunnel.

As an example, a VPN tunnel will be built based on a standard router to another network in VK Cloud. A virtual machine will be used as the VPN endpoint. The instructions for setting up the VPN tunnel can be adapted to work with any other VPN endpoint, such as a corporate firewall or other network equipment.

The VPN tunnel in the example will connect the following networks:

  • Client network — a network in VK Cloud that simulates a network in on-premises infrastructure.
  • Virtual network — a network in VK Cloud connected to a standard router.

Virtual machines will be created in each network to verify the tunnel's operability.

Preparatory steps

  1. Make sure that the OpenStack CLI is installed, and authenticate in the project.

  2. Create the networks.

    This network will act as the client network.

    When creating the network, set the following parameters:

    • Network name: clientNet.

    • SDN: Neutron. SDN Sprut is created by default.

    • Internet access: make sure this option is selected. It will allow assigning public Floating IP addresses to virtual machines in this network.

    • Router: Create new.

    • List of subnets: edit the only subnet in the list. Set the following parameters for the subnet:

      • Name: clientSubnet.
      • Address: 172.16.0.0/29.
      • Gateway: 172.16.0.1.
      • Enable DHCP: make sure this option is selected.
      • DHCP IP address pool: 172.16.0.2 - 172.16.0.6.
      • Private DNS: make sure this option is selected.
  3. Determine which routers were created for these networks. This information will be needed for further VPN configuration.

    It is further assumed that:

    • the router router_1234 was created for the clientNet network;
    • the router router_5678 was created for the vkcloudNet network.
  4. Determine the IP address of the SNAT interface for the router_5678 router:

    1. Open the page with the list of subnets for the vkcloudNet network.

    2. Click the name of the vkcloudSubnet subnet.

    3. Go to the Ports tab.

    4. Find the SNAT device port in the list of ports and copy its IP address.

  5. Create a virtual machine that will act as the VPN gateway in the clientNet client network, with the following parameters:

    • Virtual machine name: client_vpn_gw.
    • Virtual machine type: STD3-2-4.
    • Number of machines in the configuration: one.
    • Operating system: Ubuntu 22.04.
    • Network: the client network and the corresponding subnet clientNet: clientSubnet.
    • Virtual machine key: the key that will be used for the SSH connection.
    • Firewall settings: everything is allowed (all).
    • Assign external IP: make sure this option is selected.

    Choose the other virtual machine parameters at your discretion.

  6. Collect the information needed for further work. It is further assumed that:

Object

Value

Public IP address of the router_5678 router

192.0.2.100

IP address of the client_vpn_gw virtual machine in the clientSubnet subnet

172.16.0.5

Floating IP address of the client_vpn_gw virtual machine

192.0.2.200

Client subnet on the side of the client VPN gateway client_vpn_gw

172.16.0.0/29

Virtual subnet on the side of the cloud VPN gateway

10.0.0.0/29

IP address of the SNAT port in the cloud subnet

10.0.0.5

Example Infrastructure

1. Configure the VPN tunnel on the cloud network side

Create a VPN tunnel with the following parameters:

Select IKE policy — New IKE policy, and set:

  • Policy name: vkcloud-client-ike.
  • Key lifetime: 3600 seconds.
  • Authorization algorithm: sha256.
  • Encryption algorithm: aes-256.
  • IKE version: v2.
  • Diffie-Hellman group: group14.

2. Configure the VPN tunnel on the client network side

  1. Disable IP Source Guard for the VPN gateway port so that it can forward any traffic:

    1. Find the port with the private IP address 172.16.0.5 of the client_vpn_gw virtual machine. Get the ID of this port.

    2. Allow traffic from any addresses through this port:

      openstack port set <PORT_ID> --allowed-address ip-address=0.0.0.0/0
  2. Connect to the client_vpn_gw virtual machine via SSH. All further actions must be performed on this virtual machine.

  3. Enable IP Forwarding so that the virtual machine can route traffic from the private network to the VPN tunnel:

    echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.confsudo sysctl -p
  4. Install StrongSwan — an IPsec VPN implementation for Linux:

    sudo apt updatesudo apt install -y strongswan libcharon-extra-plugins libcharon-extauth-plugins libstrongswan-extra-plugins
  5. Add the VPN connection parameters on the client network side to the /etc/ipsec.conf file. These parameters are a mirror reflection of the tunnel settings made on the cloud network side.

    conn client-vkcloud-vpn   authby=secret   left=%defaultroute   leftid=192.0.2.200   leftsubnet=172.16.0.0/29   right=192.0.2.100   rightsubnet=10.0.0.0/29   ike=aes256-sha2_256-modp2048!   esp=aes256-sha2_256!   keyingtries=0   ikelifetime=3600   lifetime=8h   dpddelay=30   dpdtimeout=120   dpdaction=hold   auto=start
  6. Specify the pre-shared key (PSK) in the /etc/ipsec.secrets file. The key must match the key specified on the cloud network side:

    192.0.2.200 192.0.2.100 : PSK "<PREDEFINED_PRE-SHARED_KEY>"
  7. Restart the StrongSwan service:

    sudo systemctl restart strongswan-starter

3. Add static routes

For traffic to pass through the VPN tunnel, you need to add static routes:

  1. In your management console, open the page with the list of subnets for the vkcloudNet network.

  2. Click  for the vkcloudSubnet subnet and select Edit subnet.

  3. Make sure the Show static routes field option is selected.

  4. In the field, enter a static route to the client network 172.16.0.0/29. As the next hop, you need to specify the IP address of the SNAT interface of the router_5678 router in the vkcloudSubnet cloud subnet.

    172.16.0.0/29 - 10.0.0.5

4. Verify the VPN tunnel operability

  1. Check the status of the VPN tunnel on the VK Cloud platform side.

    To do this, open the vkcloud-client-vpn VPN page in your management console and go to the Tunnel settings tab. The VPN should be in the ACTIVE status.

  2. Create a icmp security group that allows ICMP traffic.

    In this group, create an inbound rule:

    • Type: ICMP.
    • Remote address: All IP addresses.

    This is needed so that the test virtual machines can ping each other.

  3. Create two virtual machines:

    • clientVM:

      • in the clientNet network, clientSubnet subnet;
      • with a Floating IP address for connecting to it via SSH;
      • with the default, ssh, icmp security groups.
    • vkcloudVM:

      • in the vkcloudNet network, vkcloudSubnet subnet;
      • with a Floating IP address for connecting to it via SSH;
      • with the default, ssh, icmp security groups.
  4. Determine the private IP addresses of the virtual machines in the corresponding subnets. Let:

    • clientVM have the IP address 172.16.0.4;
    • vkcloudVM have the IP address 10.0.0.4.
  5. Connect to the vkcloudVM virtual machine via SSH.

  6. Ping the clientVM virtual machine from the vkcloudVM virtual machine:

    ping 172.16.0.4

    The clientVM host should respond to the ping.

Delete unused resources

If you no longer need the created resources, delete them:

  1. Delete the virtual machines.

  2. Delete the VPN tunnel.

  3. Delete the static routes configured on the client network side.

  4. Delete the routers of the client and cloud networks.

  5. Delete the client and cloud subnets and networks.

  6. Delete the Floating IP addresses.

Was this article helpful?