| Author |
Message |
asktoby
Joined: 21 Sep 2010 Posts: 8
|
Posted: Tue 09 Nov 2010, 17:35 Post subject:
How to stop /etc/resolv.conf being overwritten at boot time? |
|
I want to have a whitelist of websites. To achieve this, I want to disable the DNS server assigned by DHCP and store the IPs in /etc/hosts.
The DNS server details are stored in /etc/resolv.conf, but dhcpcd is overwriting it each time I boot up.
Adding # nohook resolv.conf to /etc/dhcpcd.conf seemed to stop it working altogether!
chattr -i /etc/resolv.conf didn't seem to work either, perhaps because I'm using ext4.
Any bright ideas on how I can stop /etc/resolv.conf being overwritten?
|
|
Back to top
|
|
 |
noryb009
Joined: 20 Mar 2010 Posts: 511
|
Posted: Tue 09 Nov 2010, 18:10 Post subject:
|
|
Perhaps you can save the file you want to overwrite the current one (lets call it /etc/resolv.conf.backup). You can then add a small bash script in /root/Startup (there may be other places that also run on startup, not sure) that deletes /etc/resolv.conf, then copies /etc/resolv.conf.backup to /etc/resolv.conf
I don't have much experience with bash, but it would be something like:
| Code: |
#!/bin/bash
rm -f /etc/resolv.conf
cp /etc/resolv.conf.backup /etc/resolv.conf
|
|
|
Back to top
|
|
 |
shinobar

Joined: 28 May 2009 Posts: 2254 Location: Japan
|
Posted: Tue 09 Nov 2010, 22:25 Post subject:
Re: How to stop /etc/resolv.conf being overwritten at boot time? |
|
| asktoby wrote: | | Any bright ideas on how I can stop /etc/resolv.conf being overwritten? |
Not bright...
Call the dhcpcd with '-R' option.
http://www.phystech.com/download/dhcpcd_man.html
What script is calling the dhcpcd depends on what internet connecting tool you are using in your Puppy.
EDIT:
Doesn't the /etc/dhcpcd.conf line without '#' work? I have never tried.
http://roy.marples.name/cgi-bin/man-cgi?dhcpcd.conf
| asktoby wrote: | | Adding # nohook resolv.conf to /etc/dhcpcd.conf seemed to stop it working altogether! |
Sorry, I cannot follow you what you mean...
_________________ Multilingual Wary-511
Lucid Puppy Quickset edition
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
Last edited by shinobar on Tue 09 Nov 2010, 23:47; edited 1 time in total
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Tue 09 Nov 2010, 23:04 Post subject:
|
|
| Quote: | | I want to have a whitelist of websites. |
https://addons.mozilla.org/en-US/firefox/addon/3145/
a simple way
-----------------------------------------------------------------------------
or if you have to do it the way you asked and place it in /root/Startup
everything would be settled by then so you could over write it
with this replacing whatever code you need there
edit it and just finish with the EOF as the last line
| Code: |
#!/bin/bash
cat << 'EOF' >/etc/resolv.conf
# Generated by dhcpcd for interface eth0
search
nameserver XXX.XXX.X.XXX
EOF
|
_________________ slackware 14
|
|
Back to top
|
|
 |
trapster

Joined: 28 Nov 2005 Posts: 1966 Location: Maine, USA
|
Posted: Wed 10 Nov 2010, 07:30 Post subject:
|
|
Try This
_________________ trapster
Maine, USA
Asus eeepc 1005HA PU1X-BK
Frugal install:Puppeee4.31 + 1.0, Puppy4.10 + Lupu52
Currently using Puppeee-1.0 AND lupu52 w/ fluxbox
|
|
Back to top
|
|
 |
Bruce B

Joined: 18 May 2005 Posts: 10818 Location: The Peoples Republic of California
|
Posted: Thu 11 Nov 2010, 01:15 Post subject:
|
|
Variety of comments for anyone reading and no one in particular
1) I think the command is chattr +i filename not
chattr -i filename
2) A blacklist preemptively denies connections to specified sites and allows all
others
3) A whitelist allows connections to specified sites and denies all others
4) We cannot have two file names of the same name in the same directory.
We also cannot have a directory name and a file name of same name in the
same directory.
If we had a directory named /etc/resolv.conf we could not also have a file
called /etc/resolv.conf
If dhcpcd is not written to check for and delete a directory which it probably
isn't, it couldn't make a file
5) I use a static IP address. I configure IP address, mask and gateway. I do
not configure resolv.conf using ipconfig AND there is no dhcpcd utility running
when configured using a static IP
6) Browser extensions and addons will assist only the browser.
7) The hosts file will affect every application.
8) The hosts file is of no avail in blocking direct IP connections
9) An easy way to gain complete control over all outbound and inbound
data over your computer is with a proxy server. You could do this with a
localhost proxy, but I'd rather see one on your home network. If interested
let me know how. I'll tell you how I'd do it.
_________________ New! Puppy Linux Links Page
|
|
Back to top
|
|
 |
matus
Joined: 21 Jun 2012 Posts: 1
|
Posted: Thu 21 Jun 2012, 01:01 Post subject:
|
|
Just pay attention to which confing file your dhcpcd installation is using.
I am using Frisbee for network configuration and my dhcpcd server uses a config file located at /usr/local/Frisbee/dhcpcd.conf insted of the one at /etc/dhcpcd.conf
I spent a couple of hours trying to figure out why my changes to /etc/dhcpcd.conf were having no effect before finding the right file.
In order to avoid /etc/resolv.conf from being overwritten by dhcpcd when getting new IPs I just added 'nohook resolv.conf' at the end of the file and it worked at the first try.
Hope it help others.
|
|
Back to top
|
|
 |
|