Problem

On cPanel servers running AlmaLinux 8, custom DNS resolver settings (e.g., in /etc/resolv.conf) may reset after every system reboot.
This causes issues such as:

  • DNS resolution failures

  • Lost network connectivity for services relying on DNS

  • Inconsistent behavior in package updates or remote lookups

This typically happens because NetworkManager or systemd regenerates /etc/resolv.conf at boot.

Solution

To ensure custom resolver settings persist across reboots (e.g., Hetzner DNS), follow the steps below.

1. Edit /etc/resolv.conf

Open the resolver configuration file with a text editor:

sudo nano /etc/resolv.conf

Replace or add the following lines to use Hetzner's IPv4 DNS servers:

nameserver 185.12.64.1

nameserver 185.12.64.2

You can also add a third fallback DNS server (optional), such as Google's:

nameserver 8.8.8.8

Save and close the file (Ctrl + O, Enter, then Ctrl + x in nano).

2. Prevent the File from Being Overwritten

To prevent the system from modifying the file on reboot, set it as immutable:

sudo chattr +i /etc/resolv.conf

This locks the file from changes—even from system services.

Optional: Remove Protection Later

If you need to edit /etc/resolv.conf again in the future, run:

sudo chattr -i /etc/resolv.conf

Then make your changes, and reapply the lock with +i as needed.

Result

Your cPanel server running AlmaLinux 8 will now:

  • Retain the specified DNS resolvers (Hetzner) after reboots.

  • Avoid DNS-related issues caused by /etc/resolv.conf resets.

  • Provide consistent name resolution for packages, updates, and web services.

Was this answer helpful? 0 Users Found This Useful (0 Votes)