I got a server running RHEL 8.6. Whenever it gets rebooted, I get a newly created resolv.conf not containing the proper IP for my DNS.

before reboot:

nameserver X.X.X.X

after reboot:

nameserver Y.Y.Y.Y
nameserver Z.Z.Z.Z

Those IP are wrong and breaks every program relying on DNS (postfix, dig, yum, etc.) I have to manually edit the file and add X.X.X.X.

It's especially annoying as I have to disable/enable the mail system everytime.

I have seen people online talking about network manager but I am not knowledgeable enough to know exactly what to change in it. I'm basically a user, my company threw me a server and I got virtually promoted to sysAdmin but I don't get IT support for it.

how do I stop the file being overwritten?

  • 1
    Imogen does the file say "automatically generated"? If so, does it identify by which application? Sep 22, 2022 at 14:12
  • If the server is getting its DNS from your DHCP service, that is the place to fix the DNS definitions Sep 22, 2022 at 14:12

1 Answer 1


You can add a command at reboot in your root crontab :

sudo -i #then enter your root password
crontab -e

Then you can add the following line to the crontab file :

@reboot sleep 600 && echo "nameserver X.X.X.X" >> /etc/resolv.conf && sudo postfix restart

Save the file and you're good to go.

The lined added means that whenever your server gets rebooted, it will wait 10min (600s), add the right DNS to your resolv.conf then restart your mail service.

  • 1
    That's applying stickyplaster over a problem without actually fixing the underlying problem. In the meantime any emails queued and processed in that first 10 minutes will be lost - not ideal Sep 22, 2022 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .