Link to home
Start Free TrialLog in
Avatar of Xtry
Xtry

asked on

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?
Avatar of Chireru
Chireru

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.
when I pico /sbin/dhclient-script
all i see is a lot of code can you help me out please

thanks
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.
Yes. they are wrong, I dont know why
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.
Avatar of Xtry

ASKER

well its my personal unix box, it has fedora installed
how can i write off the permision from resolv.conf
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.
Avatar of Xtry

ASKER

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
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.
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).

Avatar of Xtry

ASKER

the thing i am still looking for is Gateway
The gateway is your router's IP address.
Avatar of Xtry

ASKER

I get this when i try to save changes
"IP address and gateway is not at same subnet mask!"
Avatar of Xtry

ASKER

ok what I did now was PPPoE and Disabled the
"Network Address Server Settings (DHCP)"
better?
> "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.*).

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).
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.

Avatar of Xtry

ASKER

ok how i can configure the box as a straight lan connection ?
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.
Avatar of Xtry

ASKER

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
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.  
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
Avatar of Xtry

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of mikygee
mikygee

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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
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!
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 :)
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.