๐Ÿ› ๏ธ Set Up New Server with Static IP (IPv4 Only)

Hereโ€™s a clear and structured guide for setting up a new server with a static IP address (IPv4 only) using installimage on Hetzner (or similar hosting providers). This method applies to RHEL 8/AlmaLinux 8/CloudLinux 8/9 systems.

๐Ÿงพ 1. During installimage Setup

When using installimage to deploy your OS (Hetzner Rescue System), configure the following:

  • Set IPv4 only to Yes
  • Disable IPv6 unless you specifically need it.

๐Ÿ—‚๏ธ 2. Edit DNS Resolver File

nano /etc/resolv.conf

Content:

# Hetzner Online GmbH installimage
nameserver 185.12.64.1
nameserver 185.12.64.2

๐Ÿ“„ 3. Configure Network Interface (Static IP)

Assuming your interface is enp7s0 or enp6s0. Use ip a or nmcli device to verify the interface name.

nano /etc/sysconfig/network-scripts/ifcfg-enp7s0

Template for IPv4 only:

DEVICE=enp7s0
ONBOOT=yes
BOOTPROTO=none
IPADDR=176.9.72.51          # Replace with your assigned IP
NETMASK=255.255.255.255
SCOPE="peer 176.9.72.33"    # Use Gateway IP from Hetzner
PREFIX=32
DEFROUTE=yes

Alternate example for another interface (IPv4 + IPv6, optional):

DEVICE=enp6s0
ONBOOT=yes
BOOTPROTO=none
IPADDR=94.130.160.84
NETMASK=255.255.255.255
SCOPE="peer 94.130.160.65"
PREFIX=32
DEFROUTE=yes

# Optional - for IPv6 if needed
IPV6INIT=yes
IPV6ADDR=2a01:4f8:13b:2be6::2/64
IPV6_DEFAULTGW=fe80::1
IPV6_DEFROUTE=yes

๐Ÿ›ฃ๏ธ 4. Set Default Route

nano /etc/sysconfig/network-scripts/route-enp7s0

Content:

ADDRESS0=0.0.0.0
NETMASK0=0.0.0.0
GATEWAY0=176.9.72.33     # Replace with your real Gateway IP

If using enp6s0, filename and gateway should match:

nano /etc/sysconfig/network-scripts/route-enp6s0

๐Ÿ”„ 5. Restart Network

systemctl restart network

OR, for systems using NetworkManager:

nmcli connection reload
nmcli connection up enp7s0

โœ… 6. Verify Connectivity

  • Check IP: ip a
  • Ping gateway: ping -c 4 176.9.72.33
  • Check internet: ping -c 4 8.8.8.8
  • DNS test: ping -c 4 google.com

๐Ÿ”Ž Notes

  • Hetzner usually assigns a /32 IP with a gateway outside your subnet.
  • This requires a peer route setup using SCOPE="peer GATEWAY" in the config.
  • Do not use DHCP or BOOTPROTO=dhcp.
  • Skip IPv6 if not needed โ€” or configure properly with fe80::1 as the link-local gateway.

Scroll to Top