Use Synology as an ad-blocker

Today I wondered if it was possible to use my Synology as an ad blocker.

I got the following steps from a thread at the synology forum:

I combined these steps and tested them succesfully using my DS211+ with DSM 5.2 (update 3)

GUI Settings

  1. Install the DNS Server package on your Synology.
  2. Under “Zones”, “Create” a new “Master zone”
  3. Domain type: “Forward Zone”
  4. Domain name: “”
  5. Master DNS Server: Your-Synology-IP-Address (Ex: “”)
  6. Serial format: “Date (YYYYMMDDNN)”
  7. Activate resolutions just in case the requested ip address can’t be resolved by the DNS Server. I am using alternate DNS addresses from Opennic

Telnet /SSH settings

  1. Download the script from:
  2. Copy the script to your NAS in the following directory: /var/packages/DNSServer/target/script/
  3. Give the script execute permissions: chmod +x /var/packages/DNSServer/target/script/
  4. Run the following command to execute the script: sh /var/packages/DNSServer/target/script/

Now the DNS server is installed and configured on the NAS.

How to use the DNS Server?

There are several options. You can set the new DNS address on every single device you’re using.

But it is easier to reconfigure the DNS address centrally. In my case I decided to set the new DNS address on my router.

So, there you go, no more annoying ads!

Credits go to nebulus and dMajo

Use Synology as an ad-blocker

16 thoughts on “Use Synology as an ad-blocker

    1. If you want to add an ip address manually, you have to add it to the file ad-blocker.db.
      It is located in /var/packages/DNSServer/target/named/etc/zone/data


      1. Henk says:

        This only works until the next reload. The unix shell script ( deletes the current ad-blocker.db and replaces it with the newly fetched (with wget) blacklist.
        If you want to permenantly add domain names to the blacklist, change the script contain the following:

        # Add custom blacklist to ad-blocker.db
        wget “<>/ad-blocker-custom.txt”
        cat ad-blocker-custom.txt >> ad-blocker.db
        rm “ad-blocker-custom.txt”

        Add this right before the # Include the new zone data section.

        The “cat” command merges your own blacklist with the existing one.


  1. Hi.

    Could someone point me in the direction on how to modify the script so I can download the ad-blocker.db from my own webspace? I want to run the script daily and it would be easier to edit the ad-blocker.db to add new hosts.


  2. Martin says:

    /etc/zone/data/ad-blocker.db:2342: writeable file ‘/etc/zone/master/’: already in use: /etc/zone/data/
    is the error on DMS6.0

    This error is there for every rule in the ad-blocker.db

    As far as i can tell you can’t reuse the zone file.


    1. Ken J says:

      I’m using DSM 6.0 (latest update as of today’s date) and this script works fine for me. I just added a custom domain to the script and re-ran it. Everything works for me.

      Liked by 1 person

  3. Thierry says:

    This still works fine in 2019, on my DSM 6.2.1. Thank you for the job.
    But it seems that ads are not blocked when the client uses IPV6.
    Is it possible to add IPV6 support ?


  4. HenBe says:

    Works awesomely on my DS216j (June 2019). The only flaw I can find is that I apparently can’t use wildcards like “zone “*” {…}” or regular expressions in the db file. Did anyone manage to do this?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s