Hetzner Cloud Networks Configuration

Last change on 2021-12-21 • Created on 2020-07-02 • ID: CL-96759

Installation of the auto-configuration package

Download the latest version of hc-utils for your OS and your architecture on: https://packages.hetzner.com/hcloud/

On Debian based distributions (Ubuntu, Debian):

 curl https://packages.hetzner.com/hcloud/deb/hc-utils_0.0.4-1_all.deb -o /tmp/hc-utils_0.0.4-1_all.deb -s
 apt install /tmp/hc-utils_0.0.4-1_all.deb

On RHEL based distributions:

CentOS 7

 curl https://packages.hetzner.com/hcloud/rpm/hc-utils-0.0.3-1.el7.noarch.rpm -o /tmp/hc-utils-0.0.3-1.el7.noarch.rpm -s
 yum install /tmp/hc-utils-0.0.3-1.el7.noarch.rpm

CentOS 8

 curl https://packages.hetzner.com/hcloud/rpm/hc-utils-0.0.4-1.el8.noarch.rpm -o /tmp/hc-utils-0.0.4-1.el8.noarch.rpm -s
 yum install /tmp/hc-utils-0.0.4-1.el8.noarch.rpm

Fedora 35

 dnf install https://packages.hetzner.com/hcloud/rpm/hc-utils-0.0.4-1.fc35.noarch.rpm

Uninstall auto-configuration package

On Debian based distributions (Ubuntu, Debian):

 apt remove hc-utils

On RHEL based distributions (Fedora, CentOS):

 yum remove hc-utils

Manual configuration via DHCP

Debian / Ubuntu

The interface for the first attached network will be named ens10 (for CX, CCX*1) or enp7s0 (for CPX, CCX*2). Additional interfaces will be name ens11 (CX, CCX*1) or enp8s0 (CPX, CCX*2) for the second and ens12 (CX, CCX*1) or enp9s0 (CPX, CCX*2) for the third.

ifup

  1. Open the configuration file with an editor:
 nano /etc/network/interfaces.d/61-my-private-network.cfg
  1. Paste the following configuration into the editor:

CX and CCX*1 (Intel CPU)

 auto ens10
 iface ens10 inet dhcp

CPX and CCX*2 (AMD CPU)

 auto enp7s0
 iface enp7s0 inet dhcp
  1. Now you should restart your network. Caution: This will reset your network connection.
 sudo service networking restart

netplan

  1. Open the configuration file with an editor:
 nano /etc/netplan/60-my-private-network.yaml
  1. Paste the following configuration into the editor:

CX and CCX*1 (Intel CPU)

network:
    version: 2
    renderer: networkd
    ethernets:
        ens10:
            dhcp4: true

CPX and CCX*2 (AMD CPU)

network:
    version: 2
    renderer: networkd
    ethernets:
        enp7s0:
            dhcp4: true
  1. Now you should restart your network. Caution: This will reset your network connection.
 sudo netplan generate
 sudo netplan apply

CentOS / Fedora

The first interface will be named like Debian/Ubuntu ens10 (for CX, CCX*1) or enp7s0 (for CPX, CCX*2), except on CentOS, where the interfaces use the traditional naming (eth1, eth2 and eth3).

  1. Open the configuration file with an editor:
 vi /etc/sysconfig/network-scripts/ifcfg-ens10
  1. Paste the following configuration into the editor:
 DEVICE=ens10
 BOOTPROTO=dhcp
 ONBOOT=yes
  1. Now you should restart your network. Caution: This will reset your network connection.
 systemctl restart network

Manual configuration of alias IPs

On Debian based distributions (Ubuntu, Debian):

  1. Open the configuration file with an editor:
 nano /etc/network/interfaces.d/61-my-private-network.cfg
  1. Paste the following configuration into the editor and replace your.ali.as.IP with one of the alias IPs. Keep in mind to increase the identifier by one when using more alias IPs.
 auto ens10:1
 iface ens10:1 inet static
    address your.ali.as.IP
    netmask 32
  1. Now you should restart your network. Caution: This will reset your network connection.
 sudo service networking restart

On RHEL based distributions: The interfaces will be named eth1 and up to eth3.

  1. Open the configuration file with an editor:
 vi /etc/sysconfig/network-scripts/ifcfg-eth1:0
  1. Paste the following configuration into the editor and replace your.ali.as.IP with one of the alias IPs. Keep in mind to increase the identifier by one when using more alias IPs.
 BOOTPROTO=static
 DEVICE=eth1:0
 IPADDR=your.ali.as.IP
 PREFIX=32
 TYPE=Ethernet
 USERCTL=no
 ONBOOT=yes
  1. Now you should restart your network. Caution: This will reset your network connection.
 systemctl restart network

Manual static configuration

On Debian based distributions (Ubuntu, Debian):

The interface for the network will be named ens10 for the first attached network, ens11 for the second and ens12 for the third.

  1. Open the configuration file with an editor:
 nano /etc/network/interfaces.d/61-my-private-network.cfg
  1. Paste the following configuration into the editor and replace private.address.ofThe.CloudServer, gateway.of.the.network and net.work.ip.range with the values of your network.
 auto ens10
 iface ens10 inet static
    address private.address.ofThe.CloudServer
    netmask 255.255.255.255
    mtu 1450
    pointopoint gateway.of.the.network
    post-up ip route add net.work.ip.range via gateway.of.the.network dev ens10
  1. Now you should restart your network. Caution: This will reset your network connection.
 sudo service networking restart

On RHEL based distributions (Fedora, CentOS):

The interfaces will be named ens10,ens11 and ens12. CentOS is still using eth0, eth1 and eth2.

  1. Open the configuration file with an editor:
 vi /etc/sysconfig/network-scripts/ifcfg-ens10
  1. Paste the following configuration into the editor and replace the private.address.ofThe.CloudServer with the private network IP of your server.
 BOOTPROTO=static
 DEVICE=ens10
 MTU=1450
 IPADDR=private.address.ofThe.CloudServer
 PREFIX=32
 TYPE=Ethernet
 USERCTL=no
 ONBOOT=yes
  1. Open the route configuration file with an editor:
 vi /etc/sysconfig/network-scripts/route-ens10
  1. Paste the following configuration into the editor and replace private.address.ofThe.CloudServer, gateway.of.the.network and net.work.ip.range with the values of your network.
 gateway.of.the.network/32 via 0.0.0.0 dev ens10 scope link
 net.work.ip.range via gateway.of.the.network dev ens10
  1. Now you should restart your network. Caution: This will reset your network connection.
 systemctl restart network

Manual Configuration for Windows based systems

  1. Access the server via RDP or HTML5 console.

  2. Open an elevated CMD.

  3. Print the interface list and get the interface ID of interface "Red Hat VirtIO Ethernet Adapter #2".

 route print ?

It should look like this:

  Interface List
  3...xx xx xx xx xx xx ......Red Hat VirtIO Ethernet Adapter
  5...xx xx xx xx xx xx ......Red Hat VirtIO Ethernet Adapter #2
  1...........................Software Loopback Interface 1
  2...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
  4...00 00 00 00 00 00 00 e0 Teredo Tunneling Pseudo-Interface
  7...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #2
  1. Add the static routes to interface by replacing mask.of.network.range, gateway.of.the.network and net.work.ip.range with the values of your network.
 route add -p gateway.of.the.network 0.0.0.0 if 5
 route add -p net.work.ip.range mask mask.of.network.range gateway.of.the.network if 5
  1. Check the interface name for the static configuration:
 netsh interface ip show config

The output should look something like this:

 Configuration for interface "Ethernet"
    DHCP enabled:                         Yes
    IP Address:                           xxx.xxx.xxx.xxx
    Subnet Prefix:                        xxx.xxx.xxx.xxx/32 (mask 255.255.255.255)
    Default Gateway:                      172.31.1.1
    Gateway Metric:                       0
    InterfaceMetric:                      5
    DNS servers configured through DHCP:  185.12.64.1
                                          185.12.64.2
    Register with which suffix:           Primary only
    WINS servers configured through DHCP: None
 Configuration for interface "Ethernet 2"
    DHCP enabled:                         Yes
    IP Address:                           private.address.ofThe.CloudServer
    Subnet Prefix:                        private.address.ofThe.CloudServer/32 (mask 255.255.255.255)
    Default Gateway:                      gateway.of.the.network
    Gateway Metric:                       0
    InterfaceMetric:                      5
    DNS servers configured through DHCP:  None
    Register with which suffix:           Primary only
    WINS servers configured through DHCP: None
 Configuration for interface "Loopback Pseudo-Interface 1"
    DHCP enabled:                         No
    IP Address:                           127.0.0.1
    Subnet Prefix:                        127.0.0.0/8 (mask 255.0.0.0)
    InterfaceMetric:                      75
    Statically Configured DNS Servers:    None
    Register with which suffix:           None
    Statically Configured WINS Servers:   None
  1. Set the IP address to interface:
 netsh interface ipv4 set address name="Ethernet 2" static private.address.ofThe.CloudServer 255.255.255.255 gateway.of.the.network 1
Table of Contents