How to permanently save nameservers? [Solved]

Issues Related to Networking (Wired and Wireless)

Moderator: Moderators

How to permanently save nameservers? [Solved]

Postby chasha420 » Tue Mar 20, 2012 11:40

Sup guys, a while back I had issues with Network manager applet & magically it just disappeared...never to return again Lol.

So I gave up on trying to get it back & went for 'dhcpcd' & it seems pretty nice in getting leases, & it's quite simple to use, even simpler to assign a fixed ip & a cloned mac addresses, etc.

Anyway the main problem that I face now is let's say I suspended my computer & when the network comes up back again sometimes I lose the saved nameservers in "/etc/resolv.conf". By the way my computer has trouble resolving DNS on it's own so I have to supply OpenDNS nameservers to the config.

So the point is how do I make sure my nameserver configuration doesn't change? I've heard of stuff like making the resolv.conf file write protected but that didn't help so far :?

Let me know what can be done.

Thanks!
Last edited by chasha420 on Tue Mar 20, 2012 18:35, edited 1 time in total.
chasha420
Technological Hen
 
Posts: 312
Joined: Thu Mar 31, 2011 15:32
Location: /dev/null

Re: How to permanently save nameservers?

Postby joost » Tue Mar 20, 2012 13:10

Preserving changes to resolv.conf
NetworkManager will attempt to write DNS information from DHCP into /etc/resolv.conf, overwriting the existing contents. To prevent this, you can set the immutable bit on the file (as root):
Code: Select all
# chattr +i /etc/resolv.conf

To modify the file in the future, first remove the immutable bit:
Code: Select all
# chattr -i /etc/resolv.conf


https://wiki.archlinux.org/index.php/Ne ... esolv.conf
joost
Sagely Hen
 
Posts: 2566
Joined: Fri Nov 17, 2006 12:11
Location: The Netherlands

Re: How to permanently save nameservers?

Postby chasha420 » Tue Mar 20, 2012 16:50

Thanks @joost....but this is what I get

Code: Select all
# chattr +i /etc/resolv.conf
chattr: Operation not supported while reading flags on /etc/resolv.conf


Not sure what to do :|
chasha420
Technological Hen
 
Posts: 312
Joined: Thu Mar 31, 2011 15:32
Location: /dev/null

Re: How to permanently save nameservers?

Postby joost » Tue Mar 20, 2012 16:59

Not sure, Google?

Code: Select all
lsattr /etc/resolv.conf
joost
Sagely Hen
 
Posts: 2566
Joined: Fri Nov 17, 2006 12:11
Location: The Netherlands

Re: How to permanently save nameservers?

Postby chasha420 » Tue Mar 20, 2012 17:32

Google didn't help much...anyway if there's any other alternative way pls let me know.

Thanks.

Edit:
Also I get the same error with lsattr

Code: Select all
lsattr /etc/resolv.conf
lsattr: Operation not supported While reading flags on /etc/resolv.conf


Also I find it quite funny how the word "While" starts with capital letter in the middle of a sentence. Pretty good engrish :mrgreen:
chasha420
Technological Hen
 
Posts: 312
Joined: Thu Mar 31, 2011 15:32
Location: /dev/null

Re: How to permanently save nameservers?

Postby joost » Tue Mar 20, 2012 18:03

Anyway on MY Sabayon system at my work I had the same problem and I resolved it like this without any problem.

Not sure why you are getting this. (I don't use chattr that often)
joost
Sagely Hen
 
Posts: 2566
Joined: Fri Nov 17, 2006 12:11
Location: The Netherlands

Re: How to permanently save nameservers?

Postby joost » Tue Mar 20, 2012 18:05

aha!

Code: Select all
xbox-360 etc # ls -l resolv.conf
lrwxrwxrwx 1 root root 26 Mar 10 15:22 resolv.conf -> resolvconf/run/resolv.conf
xbox-360 etc # lsattr resolvconf/run/resolv.conf
-------------e- resolvconf/run/resolv.conf


resolv.conf is a link to a file at a different location!
At my work it isn't like that.

So try it like this:
Code: Select all
chattr +i /etc/resolvconf/run/resolv.conf


Edit: while at this I read in the manual:
A file with the `i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.


So I'm not sure if you need to remove the link first, but give it a shot.
joost
Sagely Hen
 
Posts: 2566
Joined: Fri Nov 17, 2006 12:11
Location: The Netherlands

Re: How to permanently save nameservers?

Postby chasha420 » Tue Mar 20, 2012 18:35

Thanks man...changing attribute of the file to immutable @ /etc/resolvconf/run/resolv.conf did the trick!
chasha420
Technological Hen
 
Posts: 312
Joined: Thu Mar 31, 2011 15:32
Location: /dev/null


Return to Networking and Wireless

Who is online

Users browsing this forum: No registered users and 1 guest

cron