[HowTo] Running Adguard Home on OpenWrt

I disconnected the power and restarted the device, and everything returned to normal.

I will perform these operations later, and Then thank you.

I've been thinking of doing this. Can you put a brief how to on these forums?

Okay, I've posted it.

I haven't tried to be thorough about supporting topics like configuring AdGuard Home or writing an operating system to an SD card: these are separate issues and well-documented elsewhere. Mostly I've stuck to the parts that are distinctive about this application.

Is there a way to change the default working directory of AGH after the installation, preferably in it's configuration .yaml file?

The idea is I would like to leave the executables in /opt folder, but pipe the log / stats / filters to /tmp, where there are more spaces and will be wiped out after a reboot.


good question.

i dont see it in their Yaml spec, however

shows this

  -c, --config VALUE                 Path to the config file.
  -w, --work-dir VALUE               Path to the working directory.

I suspect that will mean the data folder (and thus the filters folder below it) will end up on the /tmp.

Maybe someway to have configs for all of them? so keep stats and filters but logins and queries are /tmp and discarded?

Maybe worth filling an issue on AGH page to ask for it?

I pointed out on my filesystem checks bug i filed with them that some routers have limited space (it doesn't check for freespace before installing updates which is kinda bad)

(edit) /etc/init.d/AdGuardHome

cmd="/opt/AdGuardHome/AdGuardHome "-s" "run""

So adding in the working directory there should tweak things. Don't forget to reference the config file as well!

(edit 2) so having thought about this for bit. I think you would have to write some sort of script that would copy/dump the files you want saving to a folder and when you reboot it copies them to the /tmp folders in preperation for AGH starting (to prepopulate the filters and to restore the stats db if u wanted it kept) However if u willing to just dump it all on reboot. then redirecting the working folder to /tmp would work fine. Functionally wise AGH works. What we are asking for is modifications for limited router space issues. Thats most likely going to end up as a low priority feature request. My disk space checks for instance are aimed at the next point release. see here : https://github.com/AdguardTeam/AdGuardHome/issues/3801

That reminds me. i did write up my upgrade script but i posted it on the other thread. I've copied it here now as well.

Limited space routers.

AGH binary takes up 35mb and during its update it will download the new binary compressed, backup your old binary and then extract and replace the old binary with the new one. This means you require 35mb x2 and the compressed file space and extraction space.

To manually do this, do an upgrade from the control panel and look for what version it wants to upgrade to in your syslog. Make sure you use the version you installed. Don't blindly copy my config :slight_smile:

AdGuardHome[5830]: 2021/11/10 16:03:30.149784 [info] Updating from v0.107.0-a.199+2fc10848 to v0.107.0-a.203+6fd9e72f. URL:https://static.adguard.com/adguardhome/edge/AdGuardHome_linux_mips_softfloat.tar.gz

SSH into your router and stop AGH.

/etc/init.d/AdGuardHome stop

download the new version to your routers /tmp area or to your laptop/pc. Then either unpack AGH binary from the compressed download over the existing binary or unpack the binary on your laptop/pc and copy it over the existing binary using something like WinSCP or equivalent.

Now restart AGH.

/etc/init.d/AdGuardHome start

(Edit) commands to do this below.

#Stop AGH
/etc/init.d/AdGuardHome stop 

#Grab updated AGH from server and save to /tmp
wget https://static.adguard.com/adguardhome/edge/AdGuardHome_linux_mips_softfloat.tar.gz -P /tmp

#unzip updated file over top of AGH in /opt
tar x -vzf /tmp/AdGuardHome_linux_mips_softfloat.tar.gz -C /opt

#cleanup /tmp
rm /tmp/AdGuardHome_linux_mips_softfloat.tar.gz

#Restart AGH
/etc/init.d/AdGuardHome start

Thank you for your quick replies. I don't really care about saving the logs / stats between reboots, so /tmp folder is a prefect fit.

Simply adding -w option to /etc/init.d/AdGuardHome didn't work, or I don't know how to modify it myself. I am thinking to create a symbolic link in /opt/AdGuardHome to point to /tmp.

[Edit] Symbolic link works the trick. I modified /etc/init.d/AdGuardHome to have a simple logic to test if /tmp/data exists, if not, then create it.

1 Like

Is there a way to get the latest snapshots install directly from OPKG?
Binaries on github are twice as big.
I use 32MB flash with only 22MB free space.

You have to wait until a "stable" version of AdGuardHome is released for the version that is in OpenWrt to be updated.

1 Like

If your router has a usb port you could use exroot to extend your space or just install AGH to the usb stick.

Just a heads up to everyone using AdGuardHome on OpenWRT on an issue I experienced a few days. I don't recall it being shared before in this topic or on AdGuardHome's GitHub page.

I had an issue the last few days where AGH would consume all available memory until the OOM killer stopped it. I was running on the most recent beta version on request of an issue I reported on AdGuardHome in GitHub's issue tracker. At first I thought there's a bug in the beta version so I rolled back to 2 previous versions (one was the stable release) and the problem persisted: start AGH, the web interface loaded but was continuously loading the dashboard, CPU usage and memory usage on OpenWRT kept on growing until the OOM killer did it's job. I also suspected a faulty USB stick that I use to run and store AGH query log's.

In the end it turned out to be a problem in a large DNS blocklist I used. I don't know what the problem was, the file itself is around 93MB on disk and head and tail seemed fine. I disabled that blocklist and AGH was running fine again. I emptied the contents ( > $ADGUARDHOME/data/filters/5.txt) and forced an update via AGH web interface and all was well again.

So, in case AGH goes berserk and you can't find an obvious reason, disable DNS blocklists to quick check that.

1 Like

Was this a custom blocklist of your own, or a generally available one? If the latter, it'd be helpful if you posted the URL, both so people can avoid it and the developers can look at it and zero in on the problem. If it's custom, can you upload it either here or somewhere like github so developers and self-selected users can take a look at it? Even as crude an approach as a binary search might isolate the problem without having to trace through code.

It was this one: https://dbl.oisd.nl/
It’s the full list for network based dns blockers on https://oisd.nl/

It’s updated so the problem is fixed.

1 Like

For AdGuardHome you must use abp.oisd.nl, not dbl.oisd.nl.

Not according to https://oisd.nl/how2use.

Think you might not be reading the right section:

AdGuardHome supports basic Adblock rules and hosts files syntax:

Like so:

root@OpenWrt:/mnt/sda1/AdGuardHome/data/filters# head -30 1.txt 
! Title: AdGuard DNS filter
! Description: Filter composed of several other filters (AdGuard Base filter, Social media filter, Tracking Protection filter, Mobile ads filter, EasyList, EasyPrivacy, etc) and simplified specifically to be better compatible with DNS-level ad blocking.
! Homepage: https://github.com/AdguardTeam/AdguardSDNSFilter
! License: https://github.com/AdguardTeam/AdguardSDNSFilter/blob/master/LICENSE
! Last modified: 2021-12-04T12:07:39.096Z
! Compiled by @adguard/hostlist-compiler v1.0.12
! Source name: AdGuard Base filter ad servers
! Source: https://raw.githubusercontent.com/AdguardTeam/AdguardFilters/master/EnglishFilter/sections/adservers.txt
! Section contains list of advertising networks
! The rules with hints are at the end of file

root@OpenWrt:/mnt/sda1/AdGuardHome/data/filters# head -30 2.txt 
# AdAway default blocklist
# Blocking mobile ad providers and some analytics providers
# Project home page:
# https://github.com/AdAway/adaway.github.io/
# Fetch the latest version of this file:
# https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt
# License:
# CC Attribution 3.0 (http://creativecommons.org/licenses/by/3.0/)
# Contributions by:
# Kicelo, Dominik Schuermann.
# Further changes and contributors maintained in the commit history at
# https://github.com/AdAway/adaway.github.io/commits/master
# Contribute:
# Create an issue at https://github.com/AdAway/adaway.github.io/issues
#  localhost
::1  localhost

# [163.com] analytics.163.com crash.163.com crashlytics.163.com iad.g.163.com

root@OpenWrt:/mnt/sda1/AdGuardHome/data/filters# head -30 5.txt 
#    __ __ ____ ____                 
#   /  (  / ___(    \
#  (  O )(\___ \) D (
#   \__(__(____(____/
#  Title: oisd full      
#  Syntax: dbl       
#  Entries: 1039441
#  TimeUpdated: 2021-12-04T15:01:26+01:00     
#  Maintainer: sjhgvr
#  Expires: 1 day (update frequency)
#  Homepage: https://oisd.nl


My understanding is that abp.oisd.nl is optimized for AdGuardHome and consumes less RAM.

I haven’t noticed a RAM issue, I also haven’t seen a particular reason when to use which syntax, since AGH supports both. I did find a response in a topic however from the creator of oisd.nl and there he states that for AGH you’re better of using abp instead of dbl. I didn’t know that until now so I’m going to switch to the abp variant. Thank you for telling me that.

replaced dbl with abp, smaller file size on disk and slightly more free memory :+1:

1 Like

Just of of interest, how many rules are in that list? at 93mb it has to be rather considerable.

One of the reasons i use the lists i do is down to memory. While big lists have their place, we have to bear in mind that what we are doing here is adding AGH to OpenWrt routers. This usually means limitations on disk space and memory, especially for older routers. OpenWrt already has depreciated 4 and 8mb routers. I'm running a 128mb BT Hub 5. I can get about 140k of filter rules before i run into memory issues. The bigger problem is the disk space and AGH binary being 35mb alone. Its why i created my script to do updates and filed an issue on AGH's hub. https://github.com/AdguardTeam/AdGuardHome/issues/3801

You can always add more filters if your hardware is powerful enough. But just remember about smaller less powerful routers too. :slight_smile:

(edit - For those wondering whats coming next in AGH - https://github.com/AdguardTeam/AdGuardHome/milestone/37 )

https://github.com/AdguardTeam/AdGuardHome/issues/2830 is potentially the bit we have been waiting for to have AGH take over DHCP from OpenWrt.