Dedicated Servers can be attached to Cloud Private Networks. This will enable Cloud and Dedicated Servers to reach each other via their private Network links. For example if you run your Web Frontends on Cloud Servers and your Database on a Dedicated Server you can use the private link to connect both.
It works by using the existing private network mechanisms for both systems:
- Private Networking for Cloud is done by creating a "Network" and adding your Cloud Servers to it.
- Private networking for Dedicated Servers is done by creating a "vSwitch" and attaching your Dedicated Servers to it.
Both systems are then coupled by creating a Cloud Network Subnet of type "vSwitch" which links the existing Cloud Network to the existing vSwitch. The network settings on the Cloud Servers are configured automatically. The Dedicated Servers require a special network configuration inside their Operating System for the coupling to work.
Example of a coupled configuration:
For the rest of the document we will assume that:
Your Cloud Network is
10.0.0.0/24for Cloud Servers.
10.0.0.2is assigned to your Cloud Server
10.0.1.0/24for your vSwitch Connection. IP
10.0.1.2is being used by your Dedicated Server
- You have a vSwitch with vlan-id
- Your dedicated server has the network interface
enp0s31f6as its public network interface.
You might need to replace the values listed above with the actual values of your setup.
You must have an existing Cloud Network with attached Cloud Servers. The Cloud Servers must be able to ping each other using their private IP addresses.
A Cloud Server
cloudserver01 attached to a Cloud Network looks like this:
A Dedicated Server vSwitch must already exist in Robot and the relevant servers must be attached to it. However no private network configuration should be done on the Dedicated Servers yet. Follow this tutorial to create your vSwitch but skip the part for configuring your server operating system.
A vSwitch with vlan-id 4000 and one Dedicated Server called
ex41 attached will look like this:
Go to Cloud Console. Networks, click your existing network and select the Subnets tab.
Click Add Subnet:
Check "Enable dedicated server vSwitch connection" and select the existing vSwitch you want to couple your private network with. You can also pick an IP range your Dedicated Servers will use or go with the default one.
Afterwards click "Add Subnet". You will receive instructions on how to configure the network on your Dedicated Servers:
You can either follow these instructions - making sure to replace the network interface name, the vSwitch vlan id as well as the Dedicated Server IP with the correct values - or you can manually execute them using Step 2 of this article.
Your Cloud Network and the vSwitch are now coupled.
For Cloud Servers the network configuration inside your operating system ist automatically done. For Dedicated Servers you need to do this configuration yourself. The necessary steps for a non persistent configuration were detailed in the "Configuration of your dedicated Server" dialogue in Step 1. The reason for the configuration is explained in this step.
- Setup a network interface for the vSwitch vlan (tagged vlan packets) and configure an mtu of
- On that interface: Configure an IP-Address from the IP range of the subnet of type vSwitch (
10.0.1.2in example above) and set the first IP address of that subnet as gateway (
10.0.1.1in example). Make sure that every Dedicated Server uses its own, unique private IP address.
- Configure a route for the network IP range pointing to the gateway (
10.0.0.0/16 gw 10.0.1.1in example above)
enp0s31f6 (usually called eth0, enp6s0 or enp0s31f6), VLAN 4000
Cloud Server Subnet:
vSwitch Server Subnet:
10.0.1.2 for your Dedicated Server
# /etc/network/interfaces auto enp0s31f6.4000 iface enp0s31f6.4000 inet static address 10.0.1.2 netmask 255.255.255.0 vlan-raw-device enp0s31f6 mtu 1400 up ip route add 10.0.0.0/16 via 10.0.1.1 dev enp0s31f6.4000 down ip route del 10.0.0.0/16 via 10.0.1.1 dev enp0s31f6.4000
Newer instances of installimage create netplan-based network configurations on Ubuntu 18.04. The
/etc/systemd/network/ directory will be empty. To set up the vlan, you need to change the netplan file:
#/etc/netplan/01-netcfg.yaml ### Hetzner Online GmbH installimage network: version: 2 renderer: networkd ethernets: enp0s31f6: addresses: ... vlans: enp0s31f6.4000: id: 4000 link: enp0s31f6 mtu: 1400 addresses: - 10.0.1.2/24 routes: - to: "10.0.0.0/16" via: "10.0.1.1"
After that you have to execute the following commands and the network should be available:
sudo /lib/netplan/generate sudo systemctl restart systemd-networkd
Create two new files for
#/etc/systemd/network/10-enp0s31f6.4000.netdev [NetDev] Name=enp0s31f6.4000 Kind=vlan MTUBytes=1400 [VLAN] Id=4000
#/etc/systemd/network/10-enp0s31f6.4000.network [Match] Name=enp0s31f6.4000 [Network] Description="VLAN 4000" Address=10.0.1.2/24 [Route] Gateway=10.0.1.1 Destination=10.0.0.0/16 GatewayOnlink=yes
In newer systemd versions (v242+) you have to use the Option (
GatewayOnLink, upper case
L) in the last line.
Add the following line into file:
#/etc/systemd/network/10-enp0s31f6.network .... [Network] ... VLAN=enp0s31f6.4000
sudo systemctl restart systemd-networkd
The example values in this section reflect those of chapter Assumptions above.
Run the command to show your routes:
ip route show
10.0.0.0/16 via 10.0.0.1 dev ensXX 10.0.0.1 dev ensXX scope link
Run the command to show your routes:
ip route show
It should include the following lines.
10.0.0.0/16 via 10.0.1.1 dev enp0s31f6.4000 10.0.1.0/24 dev enp0s31f6.4000 proto kernel scope link src 10.0.1.2
The vSwitch gateway should be pingable:
$ ping 10.0.1.1 PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data. 64 bytes from 10.0.1.1: icmp_seq=1 ttl=64 time=6.45 ms ...
From Dedicated Server ping the Cloud Server IP address:
$ ping 10.0.0.2 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=62 time=26.6 ms ...