Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've added some local domains to my /etc/hosts on Ubuntu. But it rewrites it every time I reboot OS.

How and where can I add constantly my 127.0.0.1 mydomain.local?

UPD

Before reboot I edit /etc/hosts:

127.0.0.1       localhost.localdomain   localhost  mydomain.local

After reboot

127.0.0.1       localhost.localdomain   localhost
share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

/etc/hosts should look like this:

127.0.0.1       hostname.domain.local hostname localhost

Also, put your hostname in /etc/hostname

If some other program (like networkmanager) keeps changing your hostfile, you could make it imutable.

chattr +i /etc/hosts
share|improve this answer
    
yep it looks okey, but it will be rewrited automatically to default after rebooting, so all my edits will be removed –  fl00r Mar 15 '11 at 9:04
    
Does it revert to 'localhost'? –  Bart De Vos Mar 15 '11 at 9:09
    
it reverts 127.0.0.1 localhost.localdomain localhost –  fl00r Mar 15 '11 at 9:14
    
Actually putting mydomain.local to /etc/hostname helps. Now /etc/hosts still rewrites but it adds mydomain.local to ::1 ... line. Thanx! –  fl00r Mar 15 '11 at 9:17
add comment

This is caused by a bug in Ubuntu NetworkManager and there is a workaround which is detailed in this document.

share|improve this answer
add comment

Probably is because of NetworkManager. Did you tried

sudo chattr +i /etc/hosts

after modifications ? If is still not working try to remove write attribute from /etc/hosts.

sudo chmod -w /etc/hosts

Regards

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.