LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Having issue in resolv.conf (https://www.linuxquestions.org/questions/linux-networking-3/having-issue-in-resolv-conf-945647/)

dushyantgohil 05-18-2012 12:50 AM

Having issue in resolv.conf
 
hi,

i am using lamp server on Cent os 5.5, but there is issue with my resolv.conf file. after every reboot or restart of network service i need to edit the nameserver details. how can i make resolv.conf file permanent after editing.

:banghead:

fogpipe 05-18-2012 01:01 AM

Quote:

Originally Posted by dushyantgohil (Post 4681452)
hi,

i am using lamp server on Cent os 5.5, but there is issue with my resolv.conf file. after every reboot or restart of network service i need to edit the nameserver details. how can i make resolv.conf file permanent after editing.

:banghead:

I have a caching nameserver set up and the instructions in the resolv.conf originally read such that creating a resolv.conf.head file with the ip of your preferred nameserver would supersede the resolv.conf file.

it seems to have worked for me, more info here:
https://wiki.archlinux.org/index.php/Resolv.conf

jschiwal 05-18-2012 01:41 AM

Check in /etc/sysconfig/ or the config for dhclient for a setting on whether dhclient updates /etc/resolv.conf. Also Better yet, don't use dhclient on a server. All servers should have static addresses.

You can also change the attribute of the file to prevent modifying. Before resorting to this, check the boot logs for messages about modifying resolv.conf.

nikmit 05-18-2012 02:01 AM

A quick-and-dirty way of doing it, when all else fails:
chattr +i /etc/resolv.conf

This can be reverted with chattr -i quite predictably :)

dushyantgohil 05-21-2012 01:12 AM

i have used "chattr +i /etc/resolv.conf" but it is not working in my case. is any thing else which can sort out my issue?

jamrock 05-21-2012 08:20 AM

Quote:

Check in /etc/sysconfig/ or the config for dhclient for a setting on whether dhclient updates /etc/resolv.conf. Also Better yet, don't use dhclient on a server. All servers should have static addresses.

You can also change the attribute of the file to prevent modifying. Before resorting to this, check the boot logs for messages about modifying resolv.conf.

It seems as if you are using dhcp. The dhcp server appears to be resetting your resolv.conf file each time you restart. Try setting a fixed i.p. address for the network card.

jschiwal 05-22-2012 05:16 AM

The chattr problem may be due to the mount options used for the filesystem. Try adding the user_xattr option.

I second the idea of setting your network options; IP address, netmask, default gateway settings. One should be able to depend on a server's IP address. Then don't start the dhcp client service, or even uninstall it.

dushyantgohil 10-18-2012 01:42 AM

i have configured fixed ip for my server but there is no change in my issue.

DutchGeek 10-18-2012 04:18 AM

I am not sure if this is available on CentOS, but in slackware there is /etc/resolv.conf.head.
whatever you put there will be added on top to the overwritten /etc/resolv.conf

Ofcourse changing permissions or trying this is not the perfect solution.

dushyantgohil 10-18-2012 04:28 AM

Quote:

Originally Posted by DutchGeek (Post 4808905)
I am not sure if this is available on CentOS, but in slackware there is /etc/resolv.conf.head.
whatever you put there will be added on top to the overwritten /etc/resolv.conf

Ofcourse changing permissions or trying this is not the perfect solution.

there is nothing like /etc/resolv.conf.head in cent os.

dushyantgohil 10-26-2012 12:28 AM

not working yet, some one tell me is there any other way to resolve this problem.

dushyantgohil 11-07-2012 03:34 AM

no one can help me out in this?????


:confused:

bathory 11-07-2012 03:58 AM

Doh, since the chattr trick doesn't work, you can put in /etc/rc.local the following
Code:

echo "nameserver x.x.x.x" > /etc/resolv.conf
Or create a resolv.conf to your liking (e.g in your home dir) and use in the above said file:
Code:

cat /home/user/resolv.conf > /etc/resolv.conf
Not the best solutions, but since everything else fails..

dushyantgohil 11-07-2012 04:55 AM

Quote:

Originally Posted by bathory (Post 4823959)
Doh, since the chattr trick doesn't work, you can put in /etc/rc.local the following
Code:

echo "nameserver x.x.x.x" > /etc/resolv.conf

using this one already want some proper solutions

bathory 11-07-2012 08:31 AM

Quote:

using this one already want some proper solutions
I thought you want just to do your job as every solution failed
Anyway, have you looked at this approach

Regards


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