๐Ÿ–ง Setup Hetzner Cloud Server Network Config (Static IP)

Hetzner Cloud servers use point-to-point (PtP) networking with a /32 subnet and a specific gateway IP. Hereโ€™s how to configure static networking manually using ifcfg-* files.


๐Ÿ“ Step 1: Edit Interface Configuration File

Edit the file corresponding to your primary network interface (e.g., enp1s0).
Path: /etc/sysconfig/network-scripts/ifcfg-enp1s0

vi /etc/sysconfig/network-scripts/ifcfg-enp1s0

Example content:

DEVICE=enp1s0
ONBOOT=yes
BOOTPROTO=none
IPADDR=167.235.207.254
NETMASK=255.255.255.255
SCOPE="peer 172.31.1.1"
PREFIX=32
DEFROUTE=yes
  • IPADDR: Your assigned public IP from Hetzner
  • SCOPE: Use the internal gateway provided by Hetzner (visible in the control panel or via ip r)
  • PREFIX=32: Denotes a single-host route
  • NETMASK=255.255.255.255: Equivalent to /32
  • DEFROUTE=yes: Set this as the default route

๐Ÿ“ Step 2: Add Static Routing File

Create the routing file to define the gateway and default route.
Path: /etc/sysconfig/network-scripts/route-enp1s0

vi /etc/sysconfig/network-scripts/route-enp1s0

Example content:

172.31.1.1 dev enp1s0
default via 172.31.1.1 dev enp1s0

This tells the system how to reach the gateway and set it as the default route.


๐Ÿ” Step 3: Restart the Network

Use nmcli, systemctl, or ifdown/ifup to apply the configuration.

nmcli connection reload
nmcli connection up enp1s0

Or:

systemctl restart NetworkManager

โœ… Verify Configuration

ip addr show enp1s0
ip route
ping -c 4 8.8.8.8

๐Ÿ”’ Notes

  • Hetzner Cloud instances use /32 routing with PtP gateway logic.
  • The SCOPE="peer <gateway>" line enables route reachability for a peer IP not within your subnet.
  • Donโ€™t forget to disable cloud-init or Netplan (on non-RHEL distros) if manually configuring.
Scroll to Top