{"id":147,"date":"2022-11-10T13:46:57","date_gmt":"2022-11-10T19:46:57","guid":{"rendered":"https:\/\/sourceopen.com\/?p=147"},"modified":"2022-11-11T00:54:22","modified_gmt":"2022-11-11T06:54:22","slug":"howto-setup-void-zones-tools-dnsbl-dns-blocklist-like-pi-hole-on-openbsd","status":"publish","type":"post","link":"https:\/\/sourceopen.com\/index.php\/howto-setup-void-zones-tools-dnsbl-dns-blocklist-like-pi-hole-on-openbsd\/","title":{"rendered":"HOWTO: Setup void-zones-tools dnsbl DNS Blocklist (like Pi-Hole) on OpenBSD"},"content":{"rendered":"\n<p>I like to use DNS blocklists to block ads, telemetry, and potential malware. Things like Pi-Hole have been popular for a while. If you search you can also find lists to block &#8220;offensive&#8221; website domains as well, such as adult sites.<\/p>\n\n\n\n<p>There is a similar tool called <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/cyclaero\/void-zones-tools\" data-type=\"URL\" data-id=\"https:\/\/github.com\/cyclaero\/void-zones-tools\" target=\"_blank\"><em>void-zones-tools<\/em><\/a> which is designed around FreeBSD. The <em>void-zones-tools<\/em> project includes a number of DNS blocklists, and there is a method to add additional blocklists (I demonstrate one way below in the <em>cron <\/em>section).<\/p>\n\n\n\n<p>The default repository doesn&#8217;t quite run out of the box on OpenBSD. However, after a few simple changes you can get it working a treat!<\/p>\n\n\n\n<p>First download the <em>void-zones-tools<\/em> <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/cyclaero\/void-zones-tools\/archive\/refs\/heads\/master.zip\" data-type=\"URL\" data-id=\"https:\/\/github.com\/cyclaero\/void-zones-tools\/archive\/refs\/heads\/master.zip\" target=\"_blank\">zipfile <\/a>from GitHub (or use <em>git <\/em>to pull it if you prefer&#8211; all of this is covered in the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/cyclaero\/void-zones-tools#readme\" data-type=\"URL\" data-id=\"https:\/\/github.com\/cyclaero\/void-zones-tools#readme\" target=\"_blank\">README<\/a> on GitHub).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt;  ftp <a href=\"https:\/\/github.com\/cyclaero\/void-zones-tools\/archive\/refs\/heads\/master.zip\">https:\/\/github.com\/cyclaero\/void-zones-tools\/archive\/refs\/heads\/master.zip<\/a><\/code><\/pre>\n\n\n\n<p>Expand the zip:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt;  unzip master.zip<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Edit the Makefile for compilation on OpenBSD<\/strong><\/p>\n\n\n\n<p>We need to modify the Make file to enable Position Independent Code for OpenBSD:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt;  cd void-zones-tools-master\n&gt;  sed -i 's\/-fno-pic\/-fPIC\/g' Makefile<\/code><\/pre>\n\n\n\n<p>Then we can compile as usual:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt;  make<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Modify the script to use <em>ftp <\/em>instead of <em>fetch<\/em> for OpenBSD<\/strong><\/p>\n\n\n\n<p>The <em>void-zones-tools<\/em> update script ( <em>void-zones-update.sh<\/em> ) tries to find the <em>fetch<\/em> program, which is FreeBSD&#8217;s equivalent of the multipurpose downloader called <em>ftp<\/em> on OpenBSD (similar to <em>wget <\/em>or <em>curl<\/em>). For the purposes of <em>void-zones-tools<\/em> you can use OpenBSD&#8217;s <em>ftp <\/em>in place of <em>fetch<\/em>. You can edit the <em>void-zones-update.sh<\/em> (installed in <em>\/usr\/local\/bin<\/em> by default) and set the FETCH variable to point to <em>\/usr\/bin\/ftp<\/em> as well as delete or comment out the checks for <em>fetch<\/em> like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n\n#### verify the path to the fetch utility\n#if &#91; -e \"\/usr\/bin\/fetch\" ]; then\n#   FETCH=\"\/usr\/bin\/fetch\"\n#elif &#91; -e \"\/usr\/local\/bin\/fetch\" ]; then\n#   FETCH=\"\/usr\/local\/bin\/fetch\"\n#elif &#91; -e \"\/opt\/local\/bin\/fetch\" ]; then\n#   FETCH=\"\/opt\/local\/bin\/fetch\"\n#else\n#   echo \"No fetch utility can be found on the system -- Stopping.\"                                                                                 #   echo \"On Mac OS X, execute either 'sudo port install fetch' or install\"\n#   echo \"fetch from source into '\/usr\/local\/bin', and then try again.\"\n#   exit 1\n#fi\n\n# Set FETCH for OpenBSD\nFETCH=\"\/usr\/bin\/ftp\"\n\n...\n<\/code><\/pre>\n\n\n\n<p><strong>Or <\/strong>you can simply make a symlink for <em>fetch <\/em>that points to <em>ftp<\/em> :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#  ln -s \/usr\/bin\/ftp \/usr\/bin\/fetch<\/code><\/pre>\n\n\n\n<p>Either way works. OpenBSD purist may prefer to modify the script rather than create the symlink.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Install<\/strong><\/p>\n\n\n\n<p>Then install as root. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#  make install<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Execution and Auto Update Configuration<\/strong><\/p>\n\n\n\n<p>** The following section is lifted from the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/cyclaero\/void-zones-tools#readme\" data-type=\"URL\" data-id=\"https:\/\/github.com\/cyclaero\/void-zones-tools#readme\" target=\"_blank\">README <\/a>of the original <em>void-zones-tools<\/em> package with modifications to paths and command names to make it OpenBSD specific. These instructions use GNU nano as the editor. You can of course replace that with <em>vi <\/em>or <em>emacs<\/em>, etc.<\/p>\n\n\n\n<p>The tools are placed by the above command sequence into <em>\/usr\/local\/bin<\/em> .<\/p>\n\n\n\n<p>On the first run of v<em>oid-zones-update.sh<\/em>, a directory is created at <em>\/usr\/local\/etc\/void-zones\/<\/em>, which serves as the storage location for the downloaded Hosts files and\/or Domain listings. In addition a template for a custom white\/black list <em>my_void_hosts.txt<\/em> is placed into that directory, and this may be used for whitelisting some zones that are inadvertently part of the downloaded <em>Hosts<\/em> files, or for blacklisting additional zones, which are missing from the downloads. Now execute the v<em>oid-zones-update.sh<\/em> shell script:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># void-zones-update.sh<\/code><\/pre>\n\n\n\n<p>You can look at the customizable file <em>my_void_hosts.txt<\/em>:<\/p>\n\n\n\n<pre id=\"block-f97e8b25-6efc-4da0-b908-5b62a8ce1646\" class=\"wp-block-code\"><code># nano \/usr\/local\/etc\/void-zones\/my_void_hosts.txt<br><br># white list<br>1.1.1.1 my.white.dom<br><br># black list<br>0.0.0.0 my.black.dom<\/code><\/pre>\n\n\n\n<p>For whitelisting use the IP address <code>1.1.1.1<\/code>, and for blacklisting <code>0.0.0.0<\/code> shall be used. This <em>\/usr\/local\/etc\/void-zones\/my_void_hosts.txt<\/em> file  is where you would add any personal exceptions to the downloaded rules, like whitelisting specific sites that don&#8217;t work correctly if blocked, or blacklisting sites not covered by the downloaded rules, etc.<\/p>\n\n\n\n<p>The downloaded <em>Hosts<\/em> files are placed into <em>\/usr\/local\/etc\/void-zones\/<\/em> as well:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># ls -l \/usr\/local\/etc\/void-zones\n\ntotal 1876\n-rw-r--r--  1 root  wheel   13722 Jan 31  2017 away_void_hosts.txt\n-rw-r--r--  1 root  wheel  640858 Aug 17 19:16 jdom_void_list.txt\n-rw-r--r--  1 root  wheel   36982 Jun 29 19:52 mdl_void_hosts.txt\n-rw-r--r--  1 root  wheel  497673 Aug  7 11:07 mvps_void_hosts.txt\n-rw-r--r--  1 root  wheel   60257 Aug 21 05:43 pgl_void_hosts.txt\n-rw-r--r--  1 root  wheel  376421 Aug 20 14:40 sowc_void_hosts.txt\n-rw-r--r--  1 root  wheel     618 Aug 22 09:29 ucky_void_host.txt\n-rw-r--r--  1 root  wheel    9977 Aug 22 09:29 w10telm_void_hosts.txt\n-rw-r--r--  1 root  wheel     886 Aug 22 09:29 w7telm_void_hosts.txt\n-rw-r--r--  1 root  wheel    1142 Aug 22 09:29 w81telm_void_hosts.txt\n<\/code><\/pre>\n\n\n\n<p>And finally the v<em>oid-zones-update.sh<\/em> compiles (converts &amp; consolidates) all <em>Hosts<\/em> files and <em>Domain<\/em> listings into one single <em>local-void.zones<\/em> include file, and moves this into <em>\/var\/unbound\/<\/em> for direct usage with <em>Unbound<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># head \/var\/unbound\/local-void.zones\n\nlocal-zone: \"clk.cloudyisland.com\" static\nlocal-zone: \"click.silvercash.com\" static\nlocal-zone: \"oascentral.pressdemocrat.com\" static\nlocal-zone: \"s29.cnzz.com\" static\nlocal-zone: \"www.spywarespy.com\" static\nlocal-zone: \"republika.onet.pl\" static\nlocal-zone: \"preview.msn.com\" static\nlocal-zone: \"pos.baidu.com\" static\n...\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Configure Unbound to use the zones<\/strong><\/p>\n\n\n\n<p>For using the void zones method, of course <em>Unbound<\/em> must be up and running already on the given OpenBSD machine. Then edit the configuration file <em>\/var\/unbound\/etc\/unbound.conf<\/em> in order to activate ad, tracking, malware and telemetry domain filtering by <em>Unbound<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># nano \/var\/unbound\/etc\/unbound.conf<\/code><\/pre>\n\n\n\n<p><strong>Before<\/strong> any forwarder directives, e.g. <code>forward-zone:<\/code> or <code>include: \/var\/unbound\/forward.conf<\/code> add the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>include: \/var\/unbound\/local-void.zones<\/code><\/pre>\n\n\n\n<p>(<em>ed note<\/em>) I like to put it as shown here with some context from the default <em>unbound.conf<\/em>:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...    \n    # Serve zones authoritatively from Unbound to resolver clients.\n    # Not for external service.\n    #\n    \n    include: \/var\/unbound\/local-void.zones\n\n    #local-zone: \"local.\" static\n    #local-data: \"mycomputer.local. IN A 192.0.2.51\"\n...<\/code><\/pre>\n\n\n\n<p>Then restart <em>Unbound<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \/usr\/sbin\/rcctl restart unbound<\/code><\/pre>\n\n\n\n<p>For future updates execute the following command sequence which may be placed into a cron job:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \/usr\/local\/bin\/void-zones-update.sh &amp;&amp; \/usr\/sbin\/rcctl restart unbound<\/code><\/pre>\n\n\n\n<p>In order to facilitate inclusion of listings which are not part of the automated updating, 3 additional input files are passed by v<em>oid-zones-update.sh<\/em> to the conversion tool <em>host2zones <\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>x_void_list.txt\ny_void_list.txt\nz_void_list.txt\n<\/code><\/pre>\n\n\n\n<p>This mechanism can be used to include for example the <a href=\"https:\/\/github.com\/chrisaljoudi\/uBlock\/issues\/1406\">Disconnect.me<\/a> listings to the <code>hosts2zones<\/code> processing by executing the following command before updating the other zones:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># ftp -o - \\\n        https:\/\/s3.amazonaws.com\/lists.disconnect.me\/simple_ad.txt \\\n        https:\/\/s3.amazonaws.com\/lists.disconnect.me\/simple_malware.txt \\\n        https:\/\/s3.amazonaws.com\/lists.disconnect.me\/simple_tracking.txt \\\n        https:\/\/s3.amazonaws.com\/lists.disconnect.me\/simple_malvertising.txt \\\n        &gt; \/usr\/local\/etc\/void-zones\/x_void_list.txt\n<\/code><\/pre>\n\n\n\n<p>Said command would place the respective lists joined together into <em>\/usr\/local\/etc\/void-zones\/x_void_list.txt<\/em> , and on the next run of v<em>oid-zones-update.sh<\/em> that one would be converted &amp; consolidated &amp; included into the <em>local-void.zones<\/em> for filtering by <em>Unbound<\/em>. In the case these additional files are missing, the tool simply ignores these parameters.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Example cron setup for OpenBSD<\/strong><\/p>\n\n\n\n<p>Here is an example cron setup for OpenBSD. Edit your crontab for root with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># crontab -e<\/code><\/pre>\n\n\n\n<p>Then add something like the following at the bottom:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~ 5 * * * ftp -o - https:\/\/raw.githubusercontent.com\/StevenBlack\/hosts\/master\/hosts http:\/\/sysctl.org\/cameleon\/hosts http:\/\/sysctl.org\/cameleon\/hosts http:\/\/sysctl.org\/cameleon\/hosts http:\/\/sysctl.org\/cameleon\/hosts http:\/\/sysctl.org\/cameleon\/hosts >! \/usr\/local\/etc\/void-zones\/y_void_list.txt\n\n~ 6 * * * \/usr\/local\/bin\/void-zones-update.sh &amp;&amp; \/usr\/sbin\/rcctl restart unbound<\/code><\/pre>\n\n\n\n<p><strong>Note <\/strong>that the first line is all on a single line with no line breaks. You could put that in a script and run the script from cron if you want your crontab cleaner.<\/p>\n\n\n\n<p>The first crontab entry runs sometime (randomly) within the 5AM hour and uses <em>ftp <\/em>to download a series of additional blocklists (these are not included by default and you may want to use them, especially the first  one is particularly good) and concatenates them into <em>\/usr\/local\/etc\/void-zones\/y_void_list.txt <\/em>, which is one of the &#8220;extra&#8221; files for customization as describe above.<\/p>\n\n\n\n<p>The second line (remember this should be just two lines in the crontab, without line breaks) runs some time randomly within the 6AM hour and runs the v<em>oid-zones-update.sh<\/em> script and then restarts <em>unbound <\/em>to load the new data. <\/p>\n\n\n\n<p>Note you may prefer to use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/sbin\/rcctl reload unbound<\/code><\/pre>\n\n\n\n<p>which should force unbound to reload the configs without clearing its cache, but I have seen some occasional issues with this; YMMV.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>Hopefully you are now about to get the void-zones-tools dnsbl blocklist (blacklist) set up under OpenBSD in order to block ads and telemetry or block malware. Someday when I have time I will submit a pull request for updates to make the master branch work under OpenBSD by default.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I like to use DNS blocklists to block ads, telemetry, and potential malware. Things like Pi-Hole have been popular for a while. If you search you can also find lists to block &#8220;offensive&#8221; website domains as well, such as adult &hellip; <a href=\"https:\/\/sourceopen.com\/index.php\/howto-setup-void-zones-tools-dnsbl-dns-blocklist-like-pi-hole-on-openbsd\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[134,133,135,4,52,138,79,81,5,2,136,90,137,132],"_links":{"self":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts\/147"}],"collection":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/comments?post=147"}],"version-history":[{"count":7,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":156,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts\/147\/revisions\/156"}],"wp:attachment":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/media?parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/categories?post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/tags?post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}