# Rocky-linux 10 /etc/hosts not updating after applying template

**URL:** <https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859>\
**Category:** Rocky Linux Help & Support\
**Created:** [November 8, 2025, 1:10am UTC](https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859 "2025-11-08T01:10:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Theo](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@Theo](https://forums.rockylinux.org/u/Theo)\
**Post date:** [November 8, 2025, 1:10am UTC](https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859/1 "2025-11-08T01:10:01Z")

</div>

I am running a VPS at ovhCloud. New install of Rocky-10. I need to update my /etc/hosts file permanantly. To do so I edited the /etc/cloud/templates/hosts.redhat.tmp1 file and rebooted. The changes did not happen to the /etc/hosts file. I cannot figure out why. Thanks for your help.

The changes are the last two lines of the ffile.

# The following lines are desirable for IPv4 capable hosts

127.0.0.1 {{fqdn}} {{hostname}}  
127.0.0.1 localhost.localdomain localhost  
127.0.0.1 localhost4.localdomain4 localhost4

# The following lines are desirable for IPv6 capable hosts

::1 {{fqdn}} {{hostname}}  
::1 localhost.localdomain localhost  
::1 localhost6.localdomain6 localhost6  
127.0.0.1 ovh1 ovh1  
127.0.1.1 ovh1.localdomain ovh1

ovh1 is my host name.

---

<div class="post-metadata">

**Author:** ![FrankCox](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/frankcox/32/1572_2.png) [@FrankCox](https://forums.rockylinux.org/u/FrankCox)\
**Post date:** [November 8, 2025, 4:33am UTC](https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859/2 "2025-11-08T04:33:12Z")

</div>

I’m probably missing something, but why wouldn’t you just update the /etc/hosts file directly instead of going through a whole other song and dance routine?

An edit to /etc/hosts will take effect immediately and not require any reboot, unless you’re using an application or service that caches dns or hostname data, but those you can just individually restart if needed.

---

<div class="post-metadata">

**Author:** ![Theo](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@Theo](https://forums.rockylinux.org/u/Theo)\
**Post date:** [November 8, 2025, 7:35am UTC](https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859/3 "2025-11-08T07:35:44Z")

</div>

I did what you suggested but upon reboot the cloud-init rewites /etc/hosts . That is why I have to use the file I mentioned previously. Thanks for checking into this. I appreciate it.

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/iwalker/32/2599_2.png) [@iwalker](https://forums.rockylinux.org/u/iwalker)\
**Post date:** [November 8, 2025, 9:48am UTC](https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859/4 "2025-11-08T09:48:34Z")

</div>

Make your changes to /etc/hosts, and then do:

```auto
chattr +i /etc/hosts

```

it then makes the file immutable to changes. I do this at OVH with my /etc/resolv.conf because they constantly overwrite it despite me trying to get cloudinit to stop doing it.

---

<div class="post-metadata">

**Author:** ![Theo](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@Theo](https://forums.rockylinux.org/u/Theo)\
**Post date:** [November 8, 2025, 5:28pm UTC](https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859/5 "2025-11-08T17:28:53Z")

</div>

Thanks for your help. I tried to sudo vi /etc/hosts to make the changes and my passwd doesn’t work. So I log into the console as root and change my passwd to my original for my user name and no problem. ssh into my home directory and sudo doesn’t work again. Go back to my console at OVH and login as my user no problem. Made sure my user name was tied to group wheel and tried sudo again it wouldn’t take my passwd. I am going to add my username to visudo and see if that helps. When I get this working I will set my /etc/hosts. Thanks for your help. Sorry for the rant.

---

<div class="post-metadata">

**Author:** ![Theo](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@Theo](https://forums.rockylinux.org/u/Theo)\
**Post date:** [November 8, 2025, 5:49pm UTC](https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859/6 "2025-11-08T17:49:26Z")

</div>

I was able to perform everything from the console and the /etc/hosts file is set now. I will check the forum to see if anyone else had this new problem after sshing into their VPS.

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/iwalker/32/2599_2.png) [@iwalker](https://forums.rockylinux.org/u/iwalker)\
**Post date:** [November 8, 2025, 7:37pm UTC](https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859/7 "2025-11-08T19:37:19Z")

</div>

For sudo you need to be in the wheel group. Which you found out anyway 🙂 otherwise su and root password.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/1X/91b7219eec10e30013422e4df76c1d898711a5d5.svg) [@system](https://forums.rockylinux.org/u/system)\
**Post date:** [January 7, 2026, 7:37pm UTC](https://forums.rockylinux.org/t/rocky-linux-10-etc-hosts-not-updating-after-applying-template/19859/8 "2026-01-07T19:37:35Z")

</div>

Closed on January 7, 2026, 7:37pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
