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 HetznerSCOPE: Use the internal gateway provided by Hetzner (visible in the control panel or viaip r)PREFIX=32: Denotes a single-host routeNETMASK=255.255.255.255: Equivalent to/32DEFROUTE=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.
