Installing Self-Hosted AdGuard Home - DNS Server

· 2 min read
Installing Self-Hosted AdGuard Home - DNS Server

AdGuard Home is a network-wide software for blocking ads and tracking. After you set it up, it’ll cover ALL your home devices, and you don’t need any client-side software for that.

It operates as a DNS server that re-routes tracking domains to a “black hole”, thus preventing your devices from connecting to those servers. It’s based on software used for their public AdGuard DNS servers, and both share a lot of code. Likewise, it is similar to Pi-Hole with a few differences highlighted on their GitHub page.

Automated install (Unix)

prerequisites

The simplest way to install AdGuard on any Unix-like system is using their automated installations:
To install with curl run the following command:

curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v

To install with wget run the following command:

wget --no-verbose -O - https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v

To install with fetch run the following command:

fetch -o - https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v

The script also accepts some options:

  • -c <channel> to use a specified channel;
  • -r to reinstall AdGuard Home;
  • -u to uninstall AdGuard Home;
  • -v for verbose output.

Note that options -r and -u are mutually exclusive.

AdGuard supports other installation methods, such as docker and snap store as highlighted on their GitHub page here. You can also choose to build from source.

Initial Setup

Once the installation is complete, you need to visit the initial setup webpage on port 3000 i.e. http://[IP]:3000. If you are doing this on a cloud VPS, make sure the security groups allow inbound traffic from your IP.

When using Ubuntu, you will encounter an error validating ports: listen tcp 0.0.0.0:53: bind: address already in use.

This happens because the port 53 on localhost, which is used for DNS, is already taken by another program. Ubuntu comes with a local DNS called systemd-resolved, which uses the address 127.0.0.53:53 and thus prevents AdGuard Home from binding to 127.0.0.1:53.

To fix this, you need to either disable the systemd-resolved daemon or choose a different network interface and bind to an accessible IP address on it.

AdGuard Home can detect such configurations and disable systemd-resolved for you if you press the “Fix” button, which is shown near the address already in use message on the installation screen. If this does not work for you or the option is unavailable, as illustrated in the screenshot above, then do the following:

DNS=127.0.0.1
DNSStubListener=no

Specifying 127.0.0.1 as DNS server address is necessary because otherwise, the nameserver will be 127.0.0.53 which doesn’t work without DNSStubListener.
3.  Activate another resolv.conf file:

sudo mv /etc/resolv.conf /etc/resolv.conf.backup
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
  1. Restart DNSStubListener: sudo systemctl reload-or-restart systemd-resolved

After that, systemd-resolved shouldn’t be shown in the output of lsof, and AdGuard Home should be able to bind to 127.0.0.1:53
For a full guide on how to resolve different errors when setting up AdGuard, visit this web page

## Convertkit Newsletter