Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xdenb43/cc86427a69be83d26efa2b4cdbbd053d to your computer and use it in GitHub Desktop.
Save xdenb43/cc86427a69be83d26efa2b4cdbbd053d to your computer and use it in GitHub Desktop.
MikroTik AdGuard Home container installation

--> adguard home to container | by @xdenb43
--> tested on hap ax3/ROS 7.17.2+
--> defconf network 192.168.88.1/24
--> docker network 192.168.254.1/24

Install AdGuard Home (AGH) to MikroTik using container

Prerequisites

/system/device-mode/update container=yes
  • USB flash drive is formatted to ext4 and connected as /usb1
    It's also possible to use RAM and Network spaces, but please update path to follow yours config then

Let's go

  1. VETH interface and Bridge
/interface veth
add address=192.168.254.5/24 gateway=192.168.254.1 name=ADGUARD-HOME
/interface bridge
add name=Bridge-Docker port-cost-mode=short
/interface bridge port
add bridge=Bridge-Docker interface=ADGUARD-HOME
/ip address
add address=192.168.254.1/24 interface=Bridge-Docker network=192.168.254.0
  1. NAT Firewall to allow outgoing requests from AGH
/ip firewall nat
add action=masquerade chain=srcnat comment=AdGuardHome src-address=192.168.254.5
  1. Containers
    RAM limitation to 200Mb is optional
/container config
set ram-high=200.0MiB registry-url=https://registry-1.docker.io tmpdir=/usb1/docker/pull
/container mounts
add dst=/opt/adguardhome/conf name=adguard_home_conf src=/usb1/docker_configs/adguard_home
/container
add cmd="-c /opt/adguardhome/conf/AdGuardHome.yaml -h 0.0.0.0 -w /opt/adguardhome/work" entrypoint=/opt/adguardhome/AdGuardHome interface=ADGUARD-HOME logging=yes mounts=\
    adguard_home_conf root-dir=/usb1/docker/adguard_home start-on-boot=yes workdir=/opt/adguardhome/work remote-image=adguard/adguardhome:latest
  1. Check newly added container state changed from extracting to stopped
/container/print where interface=ADGUARD-HOME

image
5. Start ADH container

/container/start [find where interface=ADGUARD-HOME]

AGH is now available by ip http://192.168.254.5:3000/

Just open link
Follow initial configuration wizard

AGH as DNS server for local devices

Choose one of the options below

> Option 1 <

Just set AGH ip as DNS server, redirect DNS request to MikroTik

  • /!\ DNS FWD will work
  • /!\ No device-related dns stats will be gathered (all dns requests are coming from mikrotik)
/ip dns
set allow-remote-requests=yes servers=192.168.254.5
/ip firewall nat
add action=redirect chain=dstnat comment="Incoming DNS redirect" dst-address-type=!local dst-port=53 in-interface-list=LAN protocol=udp
add action=redirect chain=dstnat comment="Incoming DNS redirect" dst-address-type=!local dst-port=53 in-interface-list=LAN protocol=tcp

> Option 2 <

Forward all DNS requests to AGH

  • /!\ DNS FWD will NOT work
  • /!\ WILL SHOW dns stats for every LAN device
/ip firewall nat
add action=dst-nat chain=dstnat comment="local AdGuard udp -  NO NAT Loopback / local addresses only!" dst-address-type=local dst-port=53 in-interface-list=LAN protocol=udp \
    to-addresses=192.168.254.5 to-ports=53
add action=dst-nat chain=dstnat comment="local AdGuard tcp" dst-address-type=local dst-port=53 in-interface-list=LAN protocol=tcp to-addresses=192.168.254.5 to-ports=53

Additional - AGH WEB UI example

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment