0

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?

    1. Only Enable
    2. Only Start
    3. Start and Enable
    4. 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 with dnsmasq, configure dnsmasq 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 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:

  1. added the following lines in hostsblock.conf:

    postprocess() {  
        sudo systemctl reload dnsmasq.service  
    }  
    
  2. added the following line to the sudoers file:

    hostsblock ALL = (root) NOPASSWD: /usr/bin/cp

    hostsblock ALL = (root) NOPASSWD: /usr/bin/systemctl reload dnsmasq.service
    
  3. added the following line to hostsblock.conf:

    some-user ALL = (hostsblock) NOPASSWD: /usr/bin/hostsblock,/usr/bin/hostsblock-urlcheck
    
  4. 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:

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

  1. added "dnsmasq" to "hostsblock" group, according to documentation in hostsblock.conf (example 1: "dnsmasq under systemd"):

    $ sudo gpasswd -a dnsmasq hostsblock

  • Feel free to suggest a better title, or better anything else in my post. I'm looking at it and no matter how much time I've spent trying to be clear and simple, it still looks ugly. Too much info maybe? – hockeykong Mar 27 '18 at 19:34
  • I took a chance and installed dhcpcd: no error/warning message. Good. – hockeykong Mar 29 '18 at 23:02
  • Still trying to get "hostsblock" working. I did no.6 (adding "dnsmasq" user to "hostsblock" group) via cli but the effect is not shown in "Users and Groups" (gui). Posted new question about it in Ask Ubuntu: askubuntu.com/questions/1023490/… – hockeykong Apr 10 '18 at 2:21
0

dhcpcd.conf was not in its place because "dhcpcd" had never been installed, i.e. I didn't install it and it is not included in my installation of Xubuntu 16.04, which I wasn't sure about when I wrote the question.

I'm guessing that I could have, and should have, installed it before starting the installation of "hostsblock" and of "dnsmasq". If I had done so the problem would not have occurred. I just didn't know that beforehand and didn't see it anywhere in my research, and lacking experience I was maybe too cautious. Now I know that "dhcpcd" and "dnsmasq" are both installed and I think configured properly.

Unfortunately I'm not yet at the end of my travels until I have verified that "hostsblock" is functioning as intended, but I wanted to be as specific as possible with my question and not include too much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.