You are not logged in.

#1 2010-06-26 23:06:08

Andy Mack
Member
Registered: 2008-06-16
Posts: 133

Resolv.conf still being overwritten

Having added opendns servers to the resolv.conf file upon reboot they have gone. Tried the dhcpd method in the wiki but resolv.conf is left blank and cannot connect to the net.

Any ideas?

Offline

#2 2010-06-26 23:09:34

andresp
Member
Registered: 2010-05-29
Posts: 62

Re: Resolv.conf still being overwritten

Put opendns to resolv.conf.head instead.

Offline

#3 2010-06-27 22:00:08

harryNID
Member
From: P3X-1971
Registered: 2009-06-12
Posts: 117

Re: Resolv.conf still being overwritten

Speeding Up DNS Lookup and Caching (For a Basic Interfaces)

If you want the fastest servers,closet to you follow these directions.

1) Download and build Namebench from here:
http://aur.archlinux.org/packages.php?ID=32453

Build Dependencies for Namebench:  (Don't forget "tk" as it's not listed in the dependencies for a graphical interface)

 pacman -S python python-dnspython  python-jinja tk

2) After building run Namebench. It will list the fastest DNS lookup servers closet to you. Copy the "Recommended Configuration" after it finishes.

3) Optional, but highly recommended: Install dnsmasq via pacman -S dnsmasq and edit /etc/dnsmasq.conf Find the line in dnsmasq.conf that says "listen-address=", uncomment it and change it to:

listen-address=127.0.0.1

Edit /etc/rc.conf and add "dnmasq" to your daemons array. After you do that start it manually as it is off right after install. As root type:

/etc/rc.d/dnsmasq start

4) Create a new txt file (as root) and add the "Recommended Configuration" servers to it. If you use dnsmasq (and only if you use dnsmasq) then you must put "nameserver 127.0.0.1" before the other nameservers at the top. This is so it will cache all your previous lookups.

Example: Example with dnmasq (DNS numbers gotten from Namebench particular for me)

nameserver 127.0.0.1
nameserver 156.154.70.1
nameserver 209.18.47.62
nameserver 74.82.42.42

Example: Example without dnmasq

nameserver 156.154.70.1
nameserver 209.18.47.62
nameserver 74.82.42.42

Save it as /etc/resolv.conf.head

5) Again as root restart your network:

/etc/rc.d/network restart

After it finishes, open up /etc/resolve.conf in a text editor. You should now see your new nameservers as well as your old ones. Delete your old ISP DNS numbers and save. Now the important part. This is not really the best way to do this but it works. The procedure keeps dhcpcd from overwriting your resolve.conf permanently until you undo it.

Type:

chattr +i /etc/resolve.conf

this will make resolve.conf immutable thereby keeping it from being overwritten. To check to see if everything worked restart your network again and you should notice that your ISP's DNS numbers have not been recreated.

6) To undo all this (or to update your DNS entries again) just follow the above steps in reverse.

To remove the immutable attribute type:

chattr -i /etc/resolve.conf

Then update /etc/resolv.conf.head (or delete it) and restart your network. If updating don't forget to make /etc/resolve.conf immutable again before restarting your network however.

This works for me and it seem like the easiest of the ways to do it. Hope it helps!!


Edit:
I would use andresp way instead of the chattr method mentioned above as it is a far better solution than using chattr.

Last edited by harryNID (2010-06-27 22:30:05)


In solving a problem of this sort, the grand thing is to be able to reason backward. That is a very useful accomplishment, and a very easy one, but people do not practice it much. In the everyday affairs of life it is more useful to reason forward, and so the other comes to be neglected. There are fifty who can reason synthetically for one who can reason analytically.  --Sherlock Holmes

Offline

#4 2010-06-27 22:02:52

andresp
Member
Registered: 2010-05-29
Posts: 62

Re: Resolv.conf still being overwritten

"nohook resolv.conf" in /etc/dhcpcd.conf will prevent overwriting it.

chattr is bad because dhcpd will waste time trying to write to it, and it's pretty easy to forget before editing it manually.

Offline

#5 2010-06-27 22:18:32

harryNID
Member
From: P3X-1971
Registered: 2009-06-12
Posts: 117

Re: Resolv.conf still being overwritten

I have been using that trick for awhile now and I did say it wasn't the best way. It was the easiest solution at the time for me when I started doing it so I never bothered to research whether there were other newer ways.  I'll give your method a try. Thanks for the tip. We all learn something new everyday.


Edit:
It does indeed work. Again thanks for the tip.

Last edited by harryNID (2010-06-27 22:26:18)


In solving a problem of this sort, the grand thing is to be able to reason backward. That is a very useful accomplishment, and a very easy one, but people do not practice it much. In the everyday affairs of life it is more useful to reason forward, and so the other comes to be neglected. There are fifty who can reason synthetically for one who can reason analytically.  --Sherlock Holmes

Offline

Board footer

Powered by FluxBB