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/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.