[How-To-Updated 2021] Installing AdGuardHome on OpenWrt [Manual and opkg method]

I may have to redo that script to pick up the ULA prefix and add it. I thought i could shortcut and use ::1 as a shortcut and thus not need to handle the prefix. Unfortunately because my ISP lives in the dark ages I'm actually unable to test this. (They have been promising IPv6 for years... and done nothing.)

I may have to reconsider if using AGH DHCP may be a simpler option. Downside is that their DHCP is vastly inferior to OpenWrt's setup. Upside would be easier configuration as AGH would hand out the proper IP4/6 DNS to clients.

Sorry for the late response. The current behaviour is definitely invalid, since --check-config really shouldn't rewrite the configuration file.

As for the original use case, we'll probably consider adding a mechanism for setting some default values on the first run, including user information and addresses, in the future. But that will require a refactoring of the configuration handling, which should happen around v0.108.

This would aid with scripting the install and hopefully will be "Soon(tm)" as 108 builds are on edge channel now.

I've done some thinking and i think what i shall do is revamp my install script to pull ip4 and ip6 addresses from uci and thus parse those values into the script. The bonus to that is that I can remove the warnings for people who aren't using 192.168.1.1 for OpenWrt as it will use the routers config to do it instead. I'll try have this fixed for this week.

1 Like

I have one more question: how do I find out which package I should download to update adguard home? I use a xiaomi miwifi 3g, using the command uname -a, it shows the mips information, but it has the mipsle package on the adguard home github, so which of the two packages is the correct one for the mi router 3g?

Your install should self update fine.

When there is an update you should get a popup like this

The manual script i developed for tight on space routers and it was purely for my router variant. There is however no reason you couldn't adapt it for your router. However it should not be needed soon as AGH team are redoing their updating so limited space routers are handled better.

If you check your syslog you should see a line like this (even if it fails to update due to lack of space)

Wed Jan 26 20:23:30 2022 daemon.err AdGuardHome[3802]: 2022/01/26 20:23:30.005875 [info] Updating from v0.108.0-a.41+f12eaf29 to v0.108.0-a.49+90c17c79. URL:https://static.adguard.com/adguardhome/edge/AdGuardHome_linux_arm64.tar.gz

There is an issue filed for disk space and failed updates which is being worked on. Its been pushed back to 108 due to them needing to know actual sizes and compression so they can automate it better.

1 Like

Here only the blue tab appears with the message that a new update is available, but not the update now button. I even added a pendrive as extroot, followed the openwrt website tutorial, I didn't create swap.

May be worth filing an issue with AGH team. You are using the edge version or the opkg OpenWrt version?

The opkg version will require waiting for new opkg versions from the packaging team. (edit - And James has already got a new PR in - https://github.com/openwrt/packages/pull/17701 )

(edit) if you have used my thread here to install then in theory you could just re-run the install script to update your existing install.

1 Like

I installed agh using your script, the openwrt version gives some errors, so I preferred to avoid it and use your version, which works perfectly.

1 Like

Ok if you are using the edge version it should give you the update button. I'd raise an issue with AGH team but only after a full reboot #incase. Mostly because reboots fix everything... unless it doesn't. Dont you love IT?

Well it turns out you cannot pull the ipv6 address from the uci system therefore its time for some bash scripting.
(edit make sure you have the jq package installed first. opkg update then opkg install jq)

fixIP6DNS.sh

#!/bin/sh
NET_ADDR=$(/sbin/ip -o -4 addr list br-lan | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1] }')
NET_ADDR6=$(/sbin/ip -o -6 addr list br-lan scope global | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1] }')

echo "Router IPv4 : ""${NET_ADDR}"
echo "Router IPv6 : ""${NET_ADDR6}"

#delete incorrect ipv6 DNS server and replace with proper ip
uci -q delete dhcp.lan.dns

for OUTPUT in $(ip -json address list br-lan | jq -r '.[0].addr_info[] | select(.family=="inet6" and .scope=="global") | .local')
do
	echo "Adding $OUTPUT to DNS"
	uci add_list dhcp.lan.dns=$OUTPUT
done

# Save changes
uci commit dhcp

# Restart dnsmasq service to reflect changes
/etc/init.d/dnsmasq restart

For completeness change your AdGuardHome.yaml file and add your ipv6 router ip.

dns:
  bind_hosts:
  - 127.0.0.1
  - 192.168.1.1
  - ::1
  - <ipv6 address here> #replace this
  port: 53
2 Likes

Ok. Main post updated. IPv6 DNS fix is in and I split my script into two parts. The first removes your ISP DNS and sets the router DNS to use Cloudflare. You may ignore that and continue with the master install script if you wish.

The install script is now fixed for IPv6. It also looks up the first ipv4 and v6 addresses to use for installing. It uses the br-lan interface for this. If you have a different interface you will need to change the script.

1 Like

For those on routers with weaker CPUs - turning on optimistic caching in adguards DNS settings makes a huge difference to average processing time.

On my mikrotik hex s(mt7261), optimistic caching took average processing time down from ~20ms to ~4ms.

5 Likes
- <**ipv6 address here> #replace this**

I was confused on that part. Is the ipv6 address you say to add here the one that appears in br-lan, the ipv6 address that is below ipv4, which in this case is 192.168.1.1?

What values ​​did you use? I have a mi router 3g, it has the same chipset.

either run the script in the earlier post or

ip -o -6 addr list br-lan scope global | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1] }'

and put the ipv6 address it spits out into your yaml file. Its why i had the script print ipv4 and 6 addresses.


Its a single tick box in the DNS settings page.

(while this does improve speed of DNS queries, you have to understand that this will continually refresh EVERY DNS request that was passed to the server, instead of letting them expire and only cache used ones.)

1 Like

Friend, explain to me how I create the .sh files, because it is giving error in the installation. Once created, which commands should I use for them to run? I have little knowledge of linux, I know very little and .sh scripts is not one of them.

easiest way? get WinSCP and it gives you an explorer like window you can edit from.

once you create the file (you were ok with copy and pasting into vi or nano btw), Save it.
then chmod +x <name of script> that makes it executeable

then its ./<nameofscript.sh>

root@OpenWrt:~# chmod +x fixIP6DNS.sh
root@OpenWrt:~# ./fixIP6DNS.sh
Router IPv4 : 192.168.1.1
Router IPv6 : fd1a:c860:7174::1
1 Like

Got it, so it was the way I had researched, thanks for the explanation. But still something is not working for me, look what the log generated by fixIP6DNS.sh:

root@OpenWrt:~# vi fixIP6DNS.sh
root@OpenWrt:~# chmod +x fixIP6DNS.sh
root@OpenWrt:~# ./fixIP6DNS.sh
Router IPv4 : 192.168.1.1
Router IPv6 : fd0b:7a4c:589f::1
./fixIP6DNS.sh: line 11: jq: not found
BusyBox v1.33.1 (2021-10-24 09:01:35 UTC) multi-call binary.

Usage: ip [OPTIONS] address|route|link|neigh|rule [ARGS]

OPTIONS := -f[amily] inet|inet6|link | -o[neline]

ip addr add|del IFADDR dev IFACE | show|flush [dev IFACE] [to PREFIX]
ip route list|flush|add|del|change|append|replace|test ROUTE
ip link set IFACE [up|down] [arp on|off] [multicast on|off]
        [promisc on|off] [mtu NUM] [name NAME] [qlen NUM] [address MAC]
        [master IFACE | nomaster]
ip neigh show|flush [to PREFIX] [dev DEV] [nud STATE]
ip rule [list] | add|del SELECTOR ACTION
udhcpc: started, v1.33.1
udhcpc: sending discover
udhcpc: no lease, failing
root@OpenWrt:~#

This also happens when I run installAGH.sh, after it installs adguard home, this part of ipv4 and ipv6 gives the same errors generated by the previous script, here the output is not the same as yours. Am I doing something wrong? Before running installAGH.sh need to modify it in something?

. /lib/functions/network.sh
network_flush_cache
network_get_ipaddr6 addr6  "lan"
network_get_ipaddrs6 addrs6 "lan"
echo "addr6:$addr6"
echo "addrs6:$addrs6"
2 Likes

jq is a package which is likely not installed in most images, so you may need to install it first before running that script.

opkg update
opkg install jq
3 Likes

... i fought network.sh over the weekend and could NOT get it to pull properly. I could get it to pull WAN addressses fine but not lan. (your script needed an extra 6 removing.)

Its why i resorted to bash scripting instead.
(edit - does that pull ALL your ip6 addresses or just the first ULA one btw? It only pulls my lone one when i try it)

1 Like
addr6:2403:58xx:xxxx::1
addrs6:2403:58xx:xxxx::1 fda9:424a:1c04::1
1 Like