You can attach Hetzner dedicated root servers to Hetzner Cloud private networks (Networks). This will enable cloud and dedicated root servers to reach each other via their private setwork links. For example, if you run your web frontends on cloud servers, and your database on a dedicated root server, you can use the private link to connect both.
It works by using the existing private network mechanisms for both systems:
- For cloud servers, you create a "Network" and add your cloud servers to it.
- For dedicated root servers, you create a "vSwitch" and attach your dedicated root servers to it.
To couple both systems, you then create a Hetzner Cloud Network subnet, with a "vSwitch" connection, which links the existing cloud Network to the existing vSwitch. The network settings on the cloud servers are configured automatically. The dedicated root 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. Your dedicated root server uses IP
- You have a vSwitch with VLAN ID
- Your dedicated root 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 root server vSwitch must already exist on Robot, and the relevant servers must be attached to it. However you shouldn#t have done any private network configuration on the dedicated root servers yet. Follow this tutorial to create your vSwitch, but skip the part for configuring your server's operating system.
A vSwitch with VLAN ID 4000 and one attached dedicated root server called
EX41-SSD will look like this:
Go to Cloud Console, and then to 'Networks'. Click on your existing network and then on the 'Subnets' tab.
Click on 'Add subnet':
Check the box next to "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 root servers will use, or you can go with the default one.
Afterwards, click "Add subnet". You will receive instructions on how to configure the network on your dedicated root servers:
You can either follow these instructions — making sure to replace the network interface name, the vSwitch VLAN ID, and the dedicated root server IP with the correct values — or you can manually execute them using Step 2 of this article.
Your Hetzner Cloud Network and the vSwitch should now be coupled.
For cloud servers, the network configuration inside your operating system is automatically done. For dedicated root servers, you need to do this configuration yourself. You can find the necessary steps for a non persistent configuration in the "Configuration of your dedicated root server" dialogue in Step 1. Step 1 also includes the reason for the configuration.
- Set up 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 vSwitch subnet (
10.0.1.2in the example above) and set the first IP address of that subnet as a gateway (
10.0.1.1in example). Make sure that every dedicated root 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, 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 the 'Assumptions' chapter 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 your dedicated root 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 ...