NetworkManager modifies /etc/hosts

There is an annoying bug (or feature depends on point of view) every restart/reconnect managed by NetworkManager, restore the original /etc/hosts loaded on startup. I’ve made a 3 line script inspired by visudo to manual edit the hosts file and prevent the other unexpected modifies:

File like (with +x attribute): /usr/sbin/vihosts

#!/bin/sh
sudo chattr -i /etc/hosts
sudo vim /etc/hosts
sudo chattr +i /etc/hosts

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.