Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5282
  • Last Modified:

problems with resolv.conf

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
Xtry
Asked:
Xtry
  • 9
  • 8
  • 3
  • +6
1 Solution
 
ChireruCommented:
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
 
KraLordCommented:
when I pico /sbin/dhclient-script
all i see is a lot of code can you help me out please

thanks
0
 
ChireruCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
KraLordCommented:
Yes. they are wrong, I dont know why
0
 
ChireruCommented:
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
 
XtryAuthor Commented:
well its my personal unix box, it has fedora installed
how can i write off the permision from resolv.conf
0
 
ChireruCommented:
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
 
XtryAuthor Commented:
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
 
ChireruCommented:
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
 
brettmjohnsonCommented:
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
 
XtryAuthor Commented:
the thing i am still looking for is Gateway
0
 
ChireruCommented:
The gateway is your router's IP address.
0
 
XtryAuthor Commented:
I get this when i try to save changes
"IP address and gateway is not at same subnet mask!"
0
 
XtryAuthor Commented:
ok what I did now was PPPoE and Disabled the
"Network Address Server Settings (DHCP)"
better?
0
 
brettmjohnsonCommented:
> "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
 
ChireruCommented:
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
 
brettmjohnsonCommented:
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
 
XtryAuthor Commented:
ok how i can configure the box as a straight lan connection ?
0
 
ChireruCommented:
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
 
XtryAuthor Commented:
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
 
ChireruCommented:
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
 
mikygeeCommented:
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
 
XtryAuthor Commented:
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
 
mikygeeCommented:
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
 
StuartColvilleCommented:
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
 
theparadigmCommented:
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
 
StuartColvilleCommented:
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
 
petepalmerCommented:
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
 
etzyCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 9
  • 8
  • 3
  • +6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now