LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 06-17-2008, 07:33 AM   #1
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.0
Posts: 452

Rep: Reputation: Disabled
Preventing /etc/resolv.conf from bring overwitten


This is the way I believe it should be done:

change /etc/dhclient.conf by adding following:

Code:
interface "eth0" {
prepend domain-name-servers 208.67.222.222 208.67.220.220;
}
didn't work - still used old dns. I thought this saved adding DNS to resolv.conf - and thus fiddling about with it being over-written.

I then changed /etc/rc.d/rc.inet1.conf

Code:
DHCP_KEEPRESOLV[0]="yes"
This resulted in a new resolv.conf being created with no DNS addresses but "search org".

I then improvised. I added the DNS servers to resolv.conf and made it READ-ONLY (0444).

This now works. But surely this is NOT the correct way to do it?

I did not reverse the above changes - but it seems to me that that instead of changing those configuration files, I could have just made resolv.conf read-only in the first place.

What is the correct and orthodox way to add a DNS to the system?

I have a conventional desktop system connected via dhcp and it seems that my IP address is fixed.
 
Old 06-17-2008, 08:24 AM   #2
houdelou
Member
 
Registered: Nov 2004
Location: Canada
Distribution: Ubuntu
Posts: 44

Rep: Reputation: 15
When you specified DHCP_KEEP_RESOLVED="yes", did you try to add your DNS after the new resolv.conf file was created with only search in it?

If yes, one thing you could try is add the -R parameter to the dhcpcd call in rc.inet1 or wherever it is called. This parameter prevent this file to be overwritten.
 
Old 06-17-2008, 08:28 AM   #3
zQUEz
Member
 
Registered: Jun 2007
Distribution: Fedora, RHEL, Centos
Posts: 294

Rep: Reputation: 53
Not sure about slackware type systems, but on Fedora/Red Hat systems you can add an option to the ifcfg-ethx file:
PEERDNS=no
This prevents /etc/resolv.conf being updated.
 
Old 06-17-2008, 09:11 AM   #4
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.0
Posts: 452

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by houdelou View Post
When you specified DHCP_KEEP_RESOLVED="yes", did you try to add your DNS after the new resolv.conf file was created with only search in it?
No - I went straight on to add the dns and made it read-only.

I've now just changed it back to r/w and rebooted - everything's fine.

It wasn't over-written.

So I should have done an extra re-boot, it seems.


Quote:
Originally Posted by houdelou View Post
If yes, one thing you could try is add the -R parameter to the dhcpcd call in rc.inet1 or wherever it is called. This parameter prevent this file to be overwritten.
According to rc.inet1 that is what DHCP_KEEPRESOLV[0]="yes" in /etc/rc.d/rc.inet1.conf does:

Code:
# Get the configuration information from /etc/rc.d/rc.inet1.conf:
. /etc/rc.d/rc.inet1.conf
Code:
        [ "${DHCP_KEEPRESOLV[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -R"
Code:
        /sbin/dhcpcd -d -t ${DHCP_TIMEOUT[$i]:-30} ${DHCP_OPTIONS} ${1}

Thanks houdelou, I have it now set up in an orthodox manner. I can't understand why it produced a rogue resolv.conf beforehand though.
 
Old 06-17-2008, 11:09 AM   #5
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.0
Posts: 452

Original Poster
Rep: Reputation: Disabled
Which DNS is really being used?

Is there anyway to tell which DNS is being used?

/etc/dhcpc/dhcpcd-eth0.info does not show the new dns which I added, just the old ones (which are still in resolv.conf together with, but after, the new ones).

Also:

Do I still need the addition I made to /etc/dhclient.conf?

This contains the "prepend domain-name-servers" value.

This isn't about "what works" but what should work - i.e. what is the correct way of setting things up.
 
Old 06-17-2008, 11:36 AM   #6
houdelou
Member
 
Registered: Nov 2004
Location: Canada
Distribution: Ubuntu
Posts: 44

Rep: Reputation: 15
I'm not an experienced net admin so I can't tell you the normal way to do this. But I will try to do my best to help you and from what I know, you are on the good track. But it is not a usual problem because when you use DHCP, normally, it does all the work and you don't touch it.

Maybe you could try supersede instead of prepend in your dhclient.conf. Look in man dhclient.conf to know what it does. If this works, maybe you won't need DHCP_KEEPRESOLV. What I would try first is to comment the DHCP_KEEPRESOLV line, add the supersede instead of prepend and restart network services.

According to man resolv.conf the dns are tried in the order listed beginning with the first one.

To know wich dns is being used, but that can vary with each query, you can use the dig command. Look at the adress after SERVER:. There should be an adress with #53 at the end. #53 means port 53 wich is dns service port.

One trick I can give you is that instead of rebooting, try doing /etc/rc.d/inet1 restart. I think it restart all the network processes.

Last edited by houdelou; 06-17-2008 at 11:38 AM.
 
  


Reply

Tags
dns, resolvconf


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/resolv.conf lordra Red Hat 1 05-05-2006 07:54 AM
DNS Hosts.conf or resolv.conf problem mac_casey Suse/Novell 0 03-26-2006 10:21 AM
/etc/resolv.conf mustangfanatic Suse/Novell 5 10-18-2004 10:28 PM
resolv.conf jmdlcar Slackware 9 05-15-2004 12:44 PM
resolv.conf ricemark20 Linux - Networking 12 11-11-2003 05:08 PM


All times are GMT -5. The time now is 06:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration