How to use host networking with AdGuard Home on Unraid

I’m a big fan of the software for blocking ads and tracking network-wide, AdGuard Home. I’ve been using it ever since it replaced my Raspberry Pie running Pi-hole last year. AdGuard Home exists as a Docker application on Unraid and can easily be installed from the Community Applications.

The installation and setup is simple enough but for the last couple of days I’ve been struggling to set the AdGuard Home container to use host networking and not a custom network. I had a good reason for wanting to use host networking, to which I will get to in the next paragraphs.

Why use host networking with AdGuard Home

The main reason why I wanted to use host networking with AdGuard Home is that I’m interested in what my devices are doing and how often they call home or attempt to load ads. To be able to that I need to be able to identify each device individually. If you think this sounds slightly overkill, you’d be surprised how often a typical smart television attempts to call home, even if it is “turned off”.

Only a single IP in AdGuard Home

The easiest way of being able to see individual devices in the AdGuard Home dashboard is by using it as a Dynamic Host Configuration Protocol (DHCP) server, which you can only configure if you are using host networking. A DHCP server dynamically assigns an IP address and other network configuration parameters to each device on the network and is usually integrated into modems and routers. The DHCP server will pass on important information, such as your DNS servers, to your network devices. That is why you have to edit the DNS server on your router for AdGuard Home to start blocking ads and trackers network-wide.

The second issue I was having is that I couldn’t integrate AdGuard Home with Home Assistant. Home Assistant serves as my central dashboard for all my self-hosted software, so obviously AdGuard Home had to integrate with it.

Why host networking fails (at first)

Using host networking isn’t as simple as enabling in the containers settings. AdGuard Home, just like Unraid, is controlled using a web interface. By default, AdGuard Home wants to use port 80 for that interface. That port, however, is already occupied by the Unraid interface. If you select host networking and attempt to start the container, you will be greeted by an error message.

Because we want to use host networking, there is no possibility of mapping the ports, as there is when using the bridged network. Because the container doesn’t have its own IP address in host networking mode, all -p, --publish, -P, and --publish-all options are ignored.

Configuring AdGuard Home for host networking

Before getting started with the container settings, you have to make sure that you have assigned your Unraid system a static IP. You can check whether this is true in the network settings. If you are using a dynamic address you will have to stop the Docker and VM services and change the setting.

Starting AdGuard Home with custom networking

The first step is to search for AdGuard Home in the Community Applications (there should only be one container available) and installing it. The only setting to adjust is to set the network type to Custom: br0. This will only be a temporary setup, but it is required for the files we need later on to be configured. You shouldn’t be seeing any errors when using a custom network. Once AdGuard Home has started up, you can stop the container again.

AdGuard Home container using a custom network on Unraid

Editing the AdGuard Home config file

The nest step is to open up Unraid’s shell and navigate to AdGuard Home’s config folder using the following command:

cd /mnt/user/appdata/adguard_home/config/

In this folder there should be a single file titled AdGuardHome.yaml. To find out whether the file exists you can use the ls command. We are going to open this file with an editor, my preferred editor is nano, using the following command:

nano AdGuardHome.yaml

Navigate to the second line of code using your arrow key and replace port 80 with a port of your liking, as long as it isn’t occupied by any other service. I went with port 180:

bind_port: 180

Save the file by hitting CTRL + X on your keyboard and follow it up with a y and Enter (return). You have now successfully changed the vital port of your AdGuard Home instance.

Configuring the AdGuard Home container

With the AdGuardHome.yaml file adjusted, you can head back into your Unraid interface and reconfigure the AdGuard Home container. You can now select host networking and restart the container without any error messages. The web interface can be access using http://[YOUR-UNRAID-IP]:180.

AdGuard Home container using host networking on Unraid

If you were, like me, having trouble integrating Home Assistant with AdGuard Home that should also be possible after the final adjustment to the Docker container. Simply use the port 180 when configuring the integration.

Leave a comment