Solved

problems with resolv.conf

Posted on 2004-06-22
29
5,258 Views
Last Modified: 2013-12-06
i have installed fedora in my system and everytime i change the info from /etc/resolv.conf
and i reboot my server it comes back to default

; generated by /sbin/dhclient-script
nameserver 205.152.144.23
nameserver 205.152.132.23

any idea why this keep happening?
0
Comment
Question by:Xtry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
  • 3
  • +6
29 Comments
 
LVL 5

Expert Comment

by:Chireru
ID: 11375072
If you are using DHCP to configure the computer's IP address, it will update resolv.conf with the DNS servers that the DHCP server sends.

If it is important for this to be changed, modify the /sbin/dhclient-script.
0
 

Expert Comment

by:KraLord
ID: 11375113
when I pico /sbin/dhclient-script
all i see is a lot of code can you help me out please

thanks
0
 
LVL 5

Expert Comment

by:Chireru
ID: 11375223
First, I must ask why you need to change your DNS servers?  Are the ones supplied by your DHCP server wrong? -- if so, then your problem lies with the DHCP server's configuration.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Expert Comment

by:KraLord
ID: 11375231
Yes. they are wrong, I dont know why
0
 
LVL 5

Expert Comment

by:Chireru
ID: 11375274
Then you want to take a look at your DHCP configuration.  If you control the DHCP server, then what DHCP server are you using?  If you don't control it, talk to the person who does control it.

As a temporary solution, you can just take the write permission off resolv.conf.  That won't solve the problem though.
0
 

Author Comment

by:Xtry
ID: 11375637
well its my personal unix box, it has fedora installed
how can i write off the permision from resolv.conf
0
 
LVL 5

Expert Comment

by:Chireru
ID: 11375667
chmod a-w /etc/resolv.conf

I would talk to your network admin about it.  If it's a bad address for you, that means it's a bad address for everyone.  They can also issue you a static IP address, where you are outside of the DHCP system, and therefore DHCP won't update your resolv.conf file.
0
 

Author Comment

by:Xtry
ID: 11375679
Well I do have a static ip and i do have a linksys router
the fedora's LAN ip is 192.168.1.101
the windows LAN ip is 192.168.1.100
0
 
LVL 5

Expert Comment

by:Chireru
ID: 11375714
The router is giving you bad DNS servers?  That doesn't sound right.  You should have either your router's IP as the DNS server, or your ISP's DNS servers in resolv.conf.

Since you are using a static IP, you should disable the DHCP client on your fedora box, and configure it to use a static IP, and plug the DNS servers into resolv.conf.
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 11375821
Actually, when I was on ATT&Home back in Silicon Valley 3-4 years ago,
ATT would routinely give me bum DNS servers most of the time.
They would give 3 DNS servers, and 1, 2, and sometimes all 3
would be down.  At least one was crap 80% of the time.

I eventually hard-coded the Verizon servers (4.1.1.1 and 4.1.1.2 IIRC).

0
 

Author Comment

by:Xtry
ID: 11375845
the thing i am still looking for is Gateway
0
 
LVL 5

Expert Comment

by:Chireru
ID: 11375892
The gateway is your router's IP address.
0
 

Author Comment

by:Xtry
ID: 11375971
I get this when i try to save changes
"IP address and gateway is not at same subnet mask!"
0
 

Author Comment

by:Xtry
ID: 11375981
ok what I did now was PPPoE and Disabled the
"Network Address Server Settings (DHCP)"
better?
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 11376006
> "IP address and gateway is not at same subnet mask!"

and they should be.  You mentioned you have a Linksys router.
By default, the Linksys has a LAN IP address of 192.168.1.1.
Your PC should be on the same subnet (192.168.1.*).

0
 
LVL 5

Expert Comment

by:Chireru
ID: 11376112
The router should be handling PPPoE, all you need to do is set yourself a static IP address (192.168.1.something), with a 255.255.255.0 mask, and a 192.168.1.1 (the router's IP) as the gateway.  Then in resolv.conf, put the router's IP (or whatever nameservers you want).
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 11376229
Yeah, it sounds like PPoE through the NAT router is your problem.
Configure the Linux box as a straight LAN connection, preferably
with DHCP.  Allow the Linksys to give you an IP addr, Gateway,
Netmask, and DNS info via DHCP.  But let it handle the PPPoE
connection.

0
 

Author Comment

by:Xtry
ID: 11380724
ok how i can configure the box as a straight lan connection ?
0
 
LVL 5

Expert Comment

by:Chireru
ID: 11382255
I don't run Fedora, so I'm not sure how it's startup scripts work.

Generally, you want to edit your network startup script to that it sets you a static IP address.  To do it manually from the prompt, type this:
ifconfig eth0 inet 192.168.1.50 netmask 255.255.255.0 broadcast 192.168.1.255 up
And make sure that you are not running a DHCP client (dhclient or dhcpcd).

There might be a net-config or fedora-net-config or redhat-net-config command that will step you through it.
0
 

Author Comment

by:Xtry
ID: 11384138
nothing its coming back to the ips
I change them and they come back when i reboot

; generated by /sbin/dhclient-script
nameserver 67.36.189.115
nameserver 67.36.179.115
0
 
LVL 5

Expert Comment

by:Chireru
ID: 11384320
You need to stop the dhclient-script from running.  Since you are on a static IP, there is no need for a DHCP client script.  Do any of these commands get you into a network config dialogue: net-config, redhat-net-config, or fedora-net?  If you have X installed, see if the configuration offers any networking options.  
0
 
LVL 2

Expert Comment

by:mikygee
ID: 11384329
You should edit the /sbin/dhclient-script as told before, i don't have fedora so I assume they told you the right script to change.
Here's a dirty way to solve your problem.
edit the script and search for some code which looks like this or at least something with the string /etc/resolv.conf

make_resolv_conf() {
  echo search $new_domain_name >/etc/resolv.conf  
  for nameserver in $new_domain_name_servers; do  
    echo nameserver $nameserver >>/etc/resolv.conf
  done
  echo "nameserver THE_IP_ADD_OF_YOUR_DNS" >> /etc/resolv.conf # ADD THIS LINE
}

And add the last line with the dns you want.

There should be a smarter way to do it but I didn't tryed to look for it yet

bye
0
 

Author Comment

by:Xtry
ID: 11384542
I uploaded the script to my friend's website so you can see it
http://ruinonline.com/dhclient-script.txt
please help me with this
thanks a lot
0
 
LVL 2

Accepted Solution

by:
mikygee earned 500 total points
ID: 11384717
Look at the second function in this script and add the line

function make_resolv_conf() {
  if [ -n "$new_domain_name" ] || [ -n "$new_domain_name_servers" ]; then
    save_previous /etc/resolv.conf
    echo '; generated by /sbin/dhclient-script' > /etc/resolv.conf
    if [ -n "$SEARCH" ]; then
       echo search $SEARCH >> /etc/resolv.conf
    else
      if [ -n "$new_domain_name" ]; then
           echo search $new_domain_name >> /etc/resolv.conf
       fi
    fi
    for nameserver in $new_domain_name_servers; do
      echo nameserver $nameserver >>/etc/resolv.conf
    done
  echo "nameserver THE_IP_ADDRESS_OF_YOUR_DNS" >> /etc/resolv.conf # <<<==== ADD THIS LINE
  fi
}
0
 

Expert Comment

by:StuartColville
ID: 11480745
Surely all you need to do is to edit:

/etc/sysconfig/networking/devices/ifcfg-eth0

and and a line:

PEERDNS=no

then you can hardcode the DNS servers you want into resolv.conf
0
 

Expert Comment

by:theparadigm
ID: 11520180
StuartColville is half right.

Under Fedora, all you have to do is add the line:
PEERDNS=no

to
"/etc/sysconfig/network-scripts/ifcfg-eth0"
(the full path "/etc/sysconfig/networking/devices/ifcfg-eth0" is not the default if cfg path for Fedora - so, in most cases it won't work)

This will stop the dhcp client script from over-writing your /etc/resolv.conf file.
No other changes need to be made.


Another very useful option that can be used like PEERDNS is USERCTL.
USERCTL allows a non-root user to activate/deactive an interface.
For example, specifying:
USERCTL=yes
in "ifcfg-eth0" would allow a normal user to bring up/down an interface, useful for a dial-up connection.

Regards,
David
0
 

Expert Comment

by:StuartColville
ID: 11527667
True technically Redhat do refer to /etc/sysconfig/network-scripts/ as being the location to edit ifcfg-eth0 but it does seem that whichever you edit the results are the same (try it!).

Not sure why they are in two separate locations? But (for me) editing either works.

Interestingly other people specify the config files under /etc/sysconfig/networking/devices/ as the ones to edit. (Try googling: etc/sysconfig/networking/devices/ifcfg-eth0).  However, as redhat specify in their manual /etc/sysconfig/network-scripts/ it's best to stick with that : )

Well spotted David!
0
 
LVL 1

Expert Comment

by:petepalmer
ID: 11557546
Here's a quick way to get around that problem but it's a bit of a hack :)

Edit /etc/resolv.conf and set the DNS entries that you want.

Save the file and copy it to /etc/resolv.conf.real


Edit /etc/rc.local

and add the line :

cp -rf /etc/resolv.conf.real /etc/resolv.conf


Not a perfect solution but it will solve the problem without you having to play with any other settings on the system :)
0
 

Expert Comment

by:etzy
ID: 11837971
Forget about all the hacks and all the I don't really know Fedora but this is how you do it on (insert other distribution here...). On Fedora you run system-config-network in graphical mode or system-config-network-cmd in console mode and use it configure your adapter as a Static IP then enter the correct settings there (as shown in http://fedora.redhat.com/projects/config-tools/images/redhat-config-network3.png)
and it should fix it system-wide.

Note any script hacks you have done as a result of other responses should be removed as they will mess up networking on your system in future.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question