LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-18-2005, 12:08 AM   #1
libregeek
Member
 
Registered: Oct 2005
Posts: 47

Rep: Reputation: 15
How to specify a default nameserver in /etc/resolv.conf


Hello all,
The Internet connection in my network is accessed through a Fedora Core 3. This machine acts as the router and as a development machine in the network. One of the ethernet interface is configured to assign the IP address through DHCP (of the ISP). The contents in the /etc/resolv.conf is automatically assigned by the dhcp server at the ISP part.
There is also a local nameserver in my network. Now I need to have the IP address of the local nameserver in the /etc/resolv.conf. Is there any way to put some default values through dhclient? Please advice me how to do it?
regards
libregeek.

Last edited by libregeek; 11-18-2005 at 12:12 AM.
 
Old 11-18-2005, 01:12 AM   #2
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
You can create a small "dhclient-enter-hooks" script to work with the dhclient-script. Read "man dhclient-script" for more info. Let us know if you can't work out how to do it -- I'll explain more in detail then.

Cheers,
 
Old 11-18-2005, 02:24 AM   #3
libregeek
Member
 
Registered: Oct 2005
Posts: 47

Original Poster
Rep: Reputation: 15
I have gone through the man pages of dhclient. But unfortunately couldn't get the idea. Can u please explain or give me some other resources on this?
regards
libregeek
 
Old 11-18-2005, 04:43 AM   #4
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
You have to create (as root) the file "/etc/dhclient-enter-hooks" with this in it:
Code:
#!/bin/sh
#
make_resolv_conf() {
    echo "nameserver 192.168.1.1" > /etc/resolv.conf
}
With 192.168.1.1 the actual address of your DNS server.
Next you must make this script executable: use the command "chmod 755 /etc/dhclient-enter-hooks"
Then restart dhclient and see if it worked!

What this thingy does is, it overrides the default make_resolv_conf() function (in /etc/dhclient-script)
with the new behaviour, i.e. just filling in /etc/resolv.conf with whatever we want, regardless of what the DHCP server says.

Let me know if it works for you!
 
Old 11-18-2005, 05:18 AM   #5
pymehta
Member
 
Registered: Jan 2004
Posts: 54

Rep: Reputation: 15
I was just going through dhclient.conf file for my dhcp config problem. Came across append and prepend statements. See if that is useful.
 
Old 11-19-2005, 12:25 AM   #6
libregeek
Member
 
Registered: Oct 2005
Posts: 47

Original Poster
Rep: Reputation: 15
nukkel:
I have worked out your suggestion. It worked but it replaced the nameservers that where inserted by the /etc/dhclient-enter-hooks. So now my /etc/resolv.conf has only the entry of my local nameserver. This is not what I expected. I have to append the local nameserver to the list of the namservers founfd by the dhclient.

However I also tried pymehta's suggestion. it worked for me. I have entered the following piece of code in the /etc/dhclient.conf.
Code:
append domain-name-servers     192.168.202.1;
This thing did all the stuff need for me. My heartiest thanks to both of you for your time spend on my issue and for the valuable suggestions.

regards
libregeek
 
Old 11-19-2005, 11:41 AM   #7
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
Glad to hear you solved it, I misread your first post, thought you _only_ wanted your local nameserver in /etc/resolv.conf... My bad :X
 
  


Reply



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
Proliant con Suse macaruchi SUSE / openSUSE 0 10-14-2005 08:06 AM
PRO AND CON About Mac And PC ?? my-unix-dream General 5 04-21-2005 02:22 AM
pro or con the mustaches? (sorry, again) Niflheim General 5 04-16-2005 10:22 AM
pppd: nameserver -> /etc/resolv.conf ?? tredegar Linux - Networking 6 03-21-2004 07:45 AM
con kolavius patchset Abe_the_Man Linux - General 5 03-18-2004 05:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:09 AM.

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
Open Source Consulting | Domain Registration