According to everything I've read it should be in /etc
, but it's not. I did read in some old post that one may simply create one as it's a text file. (Sorry, I can't find the post anymore.) I'm not sure if I should try that, i.e. create the file, or install dhcpcd
or something else. At this point I'd rather ask than go on alone.
The background is I was trying to install hostsblock
, which led me to install dnsmasq
, which led me to dhcpcd
, and here. The dnsmask Arch Wiki page (link below) says the dhcpcd.conf
file is used to protect /etc/resolv.conf
against overwriting by dhcpd
by appending the line nohook resolv.conf
to it.
I know that dnsmasq
is installed because journalctl -u dnsmasq.service
reports the following (last line of output):
Started dnsmasq - A lightweight DHCP and caching DNS server.
dhcpcd
is NOT installed. I don't know if I can just try installing it without breaking something, and if I made mistakes (see below) how to UNDO the steps I've taken. The dnsmasq
MAN page does not mention dhcpcd
.
What I've done so far, from ~/path/hostsblock/hostsblock-master/
: Run sudo sh install.sh
to start installing "hostsblock".
- add "nobody dnsmask" to the hostblock group?
Y
add
(username) ALL = (hostsblock) NOPASSWD: q/hostsblock,q/hostsblock-urlcheck
to sudoers:Y
should I enable and/or start the hostsblock service?
- Only Enable
- Only Start
- Start and Enable
Do Nothing (Default)
2
That was perhaps a mistake:
Job for hostsblock.service failed because the control process exited with error code. See "systemctl status hostsblock.service" and "journalctl -xe" for details. -e hostsblock is now installed. Check out the configuration file under /hostsblock.conf. By default, hostsblock does not directly write to /etc/hosts or manipulate your dnsmasq daemon. To make it do so, see the instructions included in /hostsblock.conf.
So as suggested above I did:
systemctl status hostsblock.service
No apparent disaster, so I went on.
From the ~/path/hostsblock-master/
I did the following:
sudo install -Dm755 src/hostsblock.sh /usr/bin/hostsblock
sudo install -Dm644 conf/hostsblock.conf /var/lib/hostsblock/hostsblock.conf
sudo install -Dm644 conf/black.list /var/lib/hostsblock/black.list
sudo install -Dm644 conf/white.list /var/lib/hostsblock/white.list
sudo install -Dm644 conf/hosts.head /var/lib/hostsblock/hosts.head
sudo install -Dm644 systemd/hostsblock.service /usr/lib/systemd/system/hostsblock.service
sudo install -Dm644 systemd/hostsblock.timer /usr/lib/systemd/system/hostsblock.timer
That was my mistake. That was part of "For Any Others (The Hard Way)" and I had already done "For Other Linux Distros (The Easy Way)" in the Hostsblock README.md file. It should not be a problem because I checked the install.sh script and the same lines are in there, but with "$DESTDIR"
replacing /usr/bin
, "$HOMEDIR"
replacing /var/lib
, and "$systemd_dir"
replacing /var/lib/hostsblock
.
Then I did
sudo systemctl enable --now hostsblock.timer
At this point the README.md says:
To use
hostsblock
together withdnsmasq
, configurednsmasq
as DNS caching daemon. Please refer to your distribution's manual. For ArchLinux read the following: Wiki section.
I also edited /etc/dnsmasq.conf
to add the following: listen-address=127.0.0.1
.
I then went to edit /etc/resolv.conf
to add the line nameserver 127.0.0.1
but it was already there.
So here I am... Sorry, I didn't think my post was gonna be this long.
My machine is behind a router but that's it. It's not a server, just a desktop with Xubuntu 16.04 on it. There is nothing else on the LAN, not even a printer anymore.
So specifically, right now, I'm trying to "configure 'dnsmasq' as a DNS caching daemon" according to the Hostblock README.md document. After much research I ended up with two sources which I'm following, comparing them while I go forward:
- The Arch Linux wiki page
- Local DNS Cache for Faster Browsing - (blog, old)
- This is what I started with and hopefully what I will achieve: The Hostsblock README.md
The first one is for Arch so I'm not sure if it applies to Xubuntu, and the second one is old. There's also of course the dhcpcd man page but it's not helpful except for confirming that dhcpcd.conf is supposed to be in /etc/. It's not on my machine. There is a /etc/dhcp directory but no "dhcpcd.conf" in it.
Thank you in advance for any advice or comment.
P.S. (see comment no. 2) After installing "dhcpcd" I completed the steps from hostsblock README.md:
added the following lines in
hostsblock.conf
:postprocess() { sudo systemctl reload dnsmasq.service }
added the following line to the
sudoers
file:hostsblock ALL = (root) NOPASSWD: /usr/bin/cphostsblock ALL = (root) NOPASSWD: /usr/bin/systemctl reload dnsmasq.service
added the following line to
hostsblock.conf
:some-user ALL = (hostsblock) NOPASSWD: /usr/bin/hostsblock,/usr/bin/hostsblock-urlcheck
added the following line to
dnsmasq.conf
:addn-hosts=/var/lib/hostsblock/hosts.block
"dnsmasq" also apparently needs the following line in
dhclient.conf
(see Note below), to force "dhclient" to look at 127.0.0.1
before it looks elsewhere:
prepend domain-name-servers 127.0.0.1;
Note: dhclient.conf
is in /etc/dhcp
on my system. Several
web documents point to other linux distributions where it is also found in /etc
(Arch) and in /etc/dhcp3
(servers, older).
added "dnsmasq" to "hostsblock" group, according to documentation in
hostsblock.conf
(example 1: "dnsmasq under systemd"):$ sudo gpasswd -a dnsmasq hostsblock