LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   resolv.conf gets rewritten on reboot even if I chmod 444 (https://www.linuxquestions.org/questions/linux-networking-3/resolv-conf-gets-rewritten-on-reboot-even-if-i-chmod-444-a-772733/)

noalternative 12-01-2009 12:38 PM

resolv.conf gets rewritten on reboot even if I chmod 444
 
my rounter causes puppy to write an improper dns entry in resolv.conf. Consequently I have to manually write it, then I have to place a command on it to make sure it doesn't get rewritten on boot, or after a couple of hours use. I had this problem with xubuntu as well. This kind of describes the problem.

https://answers.launchpad.net/ubuntu/+question/3674

I solved this problem in ubuntu by using the chattr command.

http://ubuntuforums.org/archive/index.php/t-187042.html

Puppy won't let me do this. When I use the chattr +i /etc/resolv.conf, it gives me this error.

chattr: Inappropriate ioctl for device while reading flags on /etc/resolv.conf
#
I tried chmod 444 but it had no effect on reboot. resolv.conf was rewritten again.

How can I make sure this file does not get rewritten. Why won't chattr work?

nimnull22 12-01-2009 01:34 PM

Quote:

Originally Posted by noalternative (Post 3775933)
...
I tried cmod 444 but it had no effect on reboot. resolv.conf was rewritten again.

Do please right after reboot: ls -la /etc/resolv.conf

noalternative 12-01-2009 02:38 PM

Quote:

Originally Posted by nimnull22 (Post 3775978)
Do please right after reboot: ls -la /etc/resolv.conf

This was the output and yes it was still rewritten!


# ls -la /etc/resolv.conf
-r--r--r-- 1 root root 110 2009-12-01 14:30 /etc/resolv.conf

nimnull22 12-01-2009 03:08 PM

I think that resolv.conf can be overwritten only by DHCP daemon, witch I think starts at the boot time.
Check it.

jschiwal 12-01-2009 03:13 PM

Root can still change the file. You can run "chattr +i /etc/resolv.conf" to prevent it. It would be better to change your configuration so that the dhcp client daemon doesn't modify resolv.conf.

noalternative 12-01-2009 07:19 PM

Quote:

Originally Posted by jschiwal (Post 3776105)
Root can still change the file. You can run "chattr +i /etc/resolv.conf" to prevent it. It would be better to change your configuration so that the dhcp client daemon doesn't modify resolv.conf.

How do I modify the dhcp client?

MQMan 12-01-2009 07:27 PM

It depends on which client you use. On mine, it's -R

The man pages would be a good place to start.

Cheers.

nimnull22 12-01-2009 07:34 PM

Quote:

Originally Posted by jschiwal (Post 3776105)
You can run "chattr +i /etc/resolv.conf" to prevent it. It would be better to change your configuration so that the dhcp client daemon doesn't modify resolv.conf.

Have you try "chattr +i /etc/resolv.conf", did it helps?

To modify DHCP client you need to find out which dhcp client is it.
Then you need to find script which starts dhcp client.
Then you can read in manual page additional option, for example for dhcpcd it will be "dhcpcd -R". Then you just add that option to the startup script.

Or you can find *.cfg file for your dhgp client.
For example in OpenSuse I have in /etc/sysconfig/network/dhcp, where I can add option
"-R".

noalternative 12-02-2009 02:53 PM

Quote:

Originally Posted by nimnull22 (Post 3776410)
Have you try "chattr +i /etc/resolv.conf", did it helps?

Yes, as I stated in the original post, I get an error message when I try chattr.

To modify DHCP client you need to find out which dhcp client is it.
Then you need to find script which starts dhcp client.
Then you can read in manual page additional option, for example for dhcpcd it will be "dhcpcd -R". Then you just add that option to the startup script.

Or you can find *.cfg file for your dhgp client.
For example in OpenSuse I have in /etc/sysconfig/network/dhcp, where I can add option
"-R".

I have puppy. Anyone know where dhcp would be on puppy.

nimnull22 12-02-2009 03:37 PM

from root console: "find / -name dhcp" without ""

jschiwal 12-02-2009 11:40 PM

I don't know which of 3 DHCPC clients that puppy uses. And even for a certain distro, settings and configurations change with the version. I used to have a dhcpcd.conf file which I don't any more. If your system uses netconf, then look in it's config file for the setting "NETCONFIG_DNS_STATIC_SERVERS=". Also grep the config files in /etc/ for "resolv.conf".

Someone with puppy linux would be better able to point you to the right configuration file and setting.

jschiwal 12-03-2009 02:09 AM

You probably use either the dhcpcd or dhclient programs. According to this site: http://puppylinux.org/wikka/dhcpcd it uses dhcpcd, and it is preinstalled.

Try the Menu -> Setup -> Network wizard first. It may have the option you are looking for. Otherwise, look through your startup scripts and config files in /etc/. Many config files have their own manpages as well, and may be modified to better suit puppy linux. Look in /etc/sysconfig/network/dhcpd if it exists. There may be a line like DHCPCD_USER_OPTIONS="" where you can add the --nodns option already mentioned. You will need to explore your system here if a google search doesn't turn up an option. Setting the -i attribute of /etc/resolv.conf could be a temporary fix until you find the proper solution.


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