VK Cloud logo

Setting up a VPN tunnel using SDN Sprut

Using the advanced router, you can set up a VPN tunnel between your on-premises infrastructure network and the virtual networks of VK Cloud.

To demonstrate the advanced router configuration, two independent networks will be connected:

  • Client network — the customer's internal network.
  • Virtual network — located in VK Cloud and connected to the platform router.

To demonstrate the connection setup, the following will be created in the VK Cloud management console:

  • the vRouter01 advanced router;
  • a router interface for internet access with the address 212.233.88.21;
  • the priv_net_demo private network;
  • the priv_subnet_demo private subnet with the address 10.10.2.0/24;
  • a VM: test-vm with the address 10.10.2.213;
  • the permit-remote-cidr-in security group.

The client network will use:

  • a MikroTik router running RouterOS 7.19.3;
  • a server with Debian 12 OS;
  • IKEv2 for IPsec configuration;
  • a pre-shared key (PSK) for negotiating the IKE phase.

The network topology is as follows:

Network topology

Preparatory steps

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

  2. Go to the VK Cloud management console.

  3. Select the project.

  4. Create a network with the following parameters:

    • Network name: priv_net_demo.

    • SDN: Sprut.

    • Private DNS zone: mcs.local.

    • Router: Do not use.

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

      • Name: priv_subnet_demo.
      • Address: 10.10.2.0/24.
      • Gateway: 10.10.2.1.
      • Enable DHCP: make sure this option is selected.
      • DHCP IP address pool: 10.10.2.100 - 10.10.2.200.
      • Private DNS: make sure this option is selected.
  5. Create an advanced router with the following parameters:

    • Router type: Advanced.
    • Name: vRouter01.
    • Availability zone: Москва ME1.
    • SNAT: enable the option.
  6. Add two interfaces to the created router:

    • for connecting to the private subnet;
    • for connecting to the subnet with internet access.

    When creating the interface for connecting to the private subnet, set the following parameters:

    • Name: internal.
    • Subnet: priv_subnet_demo.
    • Specify interface IP address: enable the option.
    • Interface IP address: 10.10.2.1.
  7. Create a virtual machine with the following parameters:

    • VM name: test-vm.
    • Network: priv_net_demo.

    Note the internal IP address of the virtual machine. The example will use 10.10.2.213.

  8. Create the permit-remote-cidr-in security group.

  9. In the permit-remote-cidr-in security group, add a rule for incoming traffic with the following parameters:

    • Type: All protocols and all ports.
    • In the Remote address block, go to the IP address range tab and specify the CIDR of the private subnet: 192.168.5.0/24.
  10. Apply the permit-remote-cidr-in security group to the test-vm VM.

1. Configure the VPN tunnel on the cloud network side

  1. Go to Virtual networks → VPN.

  2. Click the Add VPN or Add button.

  3. Specify the VPN parameters:

    • SDN: Sprut.

    • IKE policy: create an IKE policy with the parameters:

      • Policy name: Demo_IKEv2_Policy.
      • Key lifetime: 28800.
      • Authentication algorithm: sha256.
      • Encryption algorithm: aes-256.
      • IKE version: v2.
      • Diffie-Hellman group: group14.
  4. Click the Next step button.

  5. Configure the IPsec policy:

    • Policy name: Demo_IPSec_Policy.
    • Key lifetime: 7200.
    • Authentication algorithm: sha256.
    • Encryption algorithm: aes-256.
    • Diffie-Hellman group: group14.
  6. Configure the endpoint groups:

    • Router: vRouter01.

    • Local Endpoint: create a local endpoint group with the parameters:

      • Name: my_local_demo_endpoint.
      • Subnet address: 10.10.2.0/24.
    • Remote Endpoint: create a remote endpoint group with the parameters:

      • Group name: my_remote_demo_endpoint.
      • Subnet address: 192.168.5.0/24.
  7. Click the Next step button.

  8. Configure the VPN tunnel:

    • Settings: Advanced.

    • Tunnel name: demo_tun.

    • Peer public IPv4 address (Peer IP): 62.176.10.113.

    • Pre-shared key (PSK): generate the key by clicking the corresponding button. Write down the key value for configuring the client network side.

    • Peer router identifier for authentication (Peer ID): 62.176.10.113.

    • Traffic flow selector: Split.

    • Initiator state: bi-directional

    • Dead Peer Detection (DPD) settings:

      • Action on dead peer detection: restart.
      • Dead peer detection interval: 15.
      • Time to detect a dead peer: 60.
  9. Click the Create VPN tunnel button.

2. Configure the VPN tunnel on the client network side

Configure the MikroTik equipment using WinBox 4 or the CLI.

  1. Prepare the IPSec Profile:

    1. Go to IP → IPsec.

    2. Go to the Profile tab.

    3. Click the New button.

    4. Specify the parameter values:

      • Name: vk-dc-prof.
      • Hash Algorithms: sha256.
      • PRF Algorithms: auto.
      • Encryption Algorithms: aes-256.
      • DH Group: modp2048.
      • Proposal Check: obey.
      • Lifetime: 28800.
      • NAT Traversal: enable the option.
      • DPD Interval: 15.
      • DPD Maximum Failures: 4.
    5. Click the OK button.

  2. Prepare the IPSec Proposal:

    1. Go to IP → IPsec.

    2. Go to the Proposal tab.

    3. Click the New button.

    4. Specify the parameter values:

      • Name: vk-dc-prof.
      • Hash Algorithms: sha256.
      • Encryption Algorithms: aes-256-cbc.
      • Lifetime: 7200.
      • PFS Group: modp2048.
    5. Click the OK button.

  3. Configure the IPsec Peer:

    1. Go to IP → IPsec.

    2. Go to the Peer tab.

    3. Click the New button.

    4. Specify the parameter values:

      • Enabled: enable the option.
      • Name: vk-dc-peer.
      • Address: 212.233.88.21.
      • Local address: 62.176.10.113.
      • Profile: vk-dc-prof (created earlier).
      • Exchange mode: IKE2
      • Send INITAL_CONTRACT: enable the option.
    5. Click the OK button.

  4. Configure the IPsec Identity:

    1. Go to IP → IPsec.

    2. Go to the Identities tab.

    3. Click the New button.

    4. Specify the parameter values:

      • Enabled: enable the option.
      • Peer: vk-dc-peer.
      • Auth. Method: pre shared key.
      • Secret: specify the value of the Pre-shared key (PSK) parameter set when configuring the VPN tunnel on the cloud network side.
    5. Click the OK button.

  5. Prepare the IPSec Policy:

    1. Go to IP → IPsec.

    2. Go to the Policy tab.

    3. Click the New button.

    4. On the General tab, specify the parameter values:

      • Enabled: enable the option.
      • Peer: vk-dc-peer.
      • Src. Address: 192.168.5.0.24.
      • Dst. Address: 10.10.2.0/24.
    5. Go to the Action tab and specify the parameter values:

      • Action: encrypt.
      • Level: require.
      • IPsec Protocol: esp.
      • Proposal: vk-dc-prop.
    6. Click the OK button.

  6. Configure the exceptions:

    1. Configure the NAT exceptions.

      NAT translation exceptions must be placed above the SNAT rule for routing traffic to the internet (rules such as action = masquerade and action = src-nat to address).

      Run the command:

      /ip firewall natadd action=accept chain=srcnat comment=srcnat_fix_for_vk_dc_router dst-address=10.10.2.0/24 src-address=192.168.5.0/24
    2. Configure the Firewall allow rule in the Forward chain to allow traffic to pass from the VK Cloud network to the local network through the IPsec VPN tunnel.

      The allow rule must be placed above the rule that blocks unknown traffic arriving at the interface.

      Run the command:

      /ip firewall filteradd action=accept chain=forward src-address=10.10.2.0/24 dst-address=192.168.5.0/24 ipsec-policy=in,ipsec in-interface=ether1

      Here ether1 is the name of the MikroTik physical interface (port) connected to the internet.

    3. Configure the Mangle rules for MSS Window optimization:

      /ip firewall mangleadd action=change-mss chain=forward dst-address=192.168.5.0/24 new-mss=1360 protocol=tcp src-address=10.10.2.0/24 tcp-flags=syn tcp-mss=!0-1360add action=change-mss chain=forward dst-address=10.10.2.0/24 new-mss=1360 protocol=tcp src-address=192.168.5.0/24 tcp-flags=syn tcp-mss=!0-1360

3. Check the VPN tunnel status

  1. Check the status on the cloud network side:

    1. List the VPN services in the project:

      openstack vpn service list
    2. Display detailed information about the service:

      openstack vpn service show 7a60f4c3-5684-43d8-b5d7-a0**********

      The Active status means that the service is active and traffic can be transmitted between the remote sites.

  2. Check the status on the client network side:

    1. Go to IP → IPsec.
    2. Go to the Policy tab.
    3. Check the status of the configured policy: the PH2 State column should display established.
  3. Check connectivity between the 192.168.5.0/24 and 10.10.2.0/24 subnets using ICMP Ping:

    1. Open a terminal session on the VM or server in the client network with the address 192.168.5.9.

    2. Ping the internal IP address of the machine in the cloud network 10.10.2.213.

      ping 10.10.2.213 -c 3

      The IP address should respond to the ping.

Delete unused resources

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

  1. Delete the virtual machine.
  2. Delete the router.
  3. Delete the subnet and the network in which the VM was located.
Was this article helpful?