riesinger / website

My personal website
https://riesinger.dev
0 stars 0 forks source link

Blocky DNS adblocking on Alpine Linux - Help/ Guidance needed #165

Closed gspannu closed 6 months ago

gspannu commented 7 months ago

Hi,

I was going through your very well written and useful article on DNS Blocky and setting up as HA (https://riesinger.dev/posts/ha-dns-adblocking-with-blocky/).

I am trying to setup Blocky on an Alpine Linux Virtual Machine (Proxmox host) but cannot figure this out. I do not want to use Docker, as I would like to use an Alpine Virtual Machine/ LXC container instead.

I have successfully installed Blocky on a Debian server as it is available as a Proxmox helper script (https://tteck.github.io/Proxmox/), but am struggling to install Blocky on an Alpine instance.

Could you provide some guide/ instructions/ weblinks as to how I could install Blocky on a standard Alpine Linux server instance?

riesinger commented 6 months ago

Sure, there's an Alpine package available for blocky: https://pkgs.alpinelinux.org/package/edge/testing/x86/blocky You could install it with apk add blocky if I remember correctly. In general, the configuration guide and documentation at https://0xerr0r.github.io/blocky/v0.23/configuration/ is quite helpful 🙂 Good luck!

gspannu commented 6 months ago

My key issue was with installing Blocky on Alpine (and not the configuration of Blocky DNS itself). I eventually managed to download, install and configure it manually.

Below is a short guide for reference (it may help someone else)...


) Search for Blocky from edge/testing repository

apk --no-cache search blocky --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing

) Install Blocky from edge/testing repository

apk --no-cache add blocky --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing

) Check that blocky has been installed. e.g. in /usr/bin

ls -lAhp /usr/bin | grep blocky

) Create the service file for Blocky

nano /etc/init.d/blocky

#!/sbin/openrc-run
name="${RC_SVCNAME}"
description="Blocky is a DNS server with ad-blocker"
command="/usr/bin/blocky"
pidfile="/run/${RC_SVCNAME}.pid"
required_files="/etc/blocky/config.yml"
command_args="-c /etc/blocky/config.yml"
command_background=yes
command_user="root:root"
output_log="/var/log/blocky/${RC_SVCNAME}.log"
error_log="/var/log/blocky/${RC_SVCNAME}.err"

) Make the above Blocky init script executable

chmod a+x /etc/init.d/blocky

) Create your config.yml file

mkdir -p /etc/blocky nano /etc/blocky/config.yml

) Start blocky manually to test if it works

blocky -c /etc/blocky/config.yml

) Press Ctrl-C to exit out

) Start Blocky service and check

rc-service blocky start rc-service blocky status

) Check that service is running

nano /var/log/blocky/blocky.log

) Check that Blocky is rinning on port 53 (or whatever port your config.yml states)

netstat -tunlp

) Enable Blocky to start at boot-up

rc-update add blocky

) Check Blocky as a service

rc-service --list | grep blocky rc-update

) Reboot machine and check that Blocky is running as expected !


riesinger commented 6 months ago

Thanks for that write-up 🙂 That's a nice reference!