Create your own, ads blocking DNS like AdGuard DNS

Siddhpura Amitkumar
3 min readOct 10, 2021

Nowadays you can see many Ads on your browser and various mobile applications. These ads help to generate revenue to that application or website owner. The problem with user is that these ads use more data (internet) and also track user’s activities.

So to prevent these ads and tracking, I have found AdGuard DNS which provides DNS address. With this we don’t need to install any software, instead we can just set AdGuard’s DNS address in our Wifi router and all connected device will be prevented from ads and tracking. But again, by setting AdGuard’s DNS, all the DNS level traffic will go to AdGuard’ server. So, I wanted to make my own solution which will work same as AdGuard’s service.

Before few weeks ago, I got solution with BIND, it is working perfectly well, so I thought to publish it to medium so other user can use same solution and can prevent their network from many ads and tracker.

First I have created Amazon AWS account, with free tier I have launched EC2 instance by selecting Ubuntu Sever 20.04 LTS.

In this instance, I have used following security settings (inbound rules).

Complete details of created instance is like below,

Now, connect to this instance with SSH and in that, download some files with below command.

git clone https://github.com/panchalamitr/AdsBlocker-DNS-BIND9.git

After cloning above repository, you can see that AdsBlocker-DNS-BIND9 directory will be created.

Now go to that directory

cd AdsBlocker-DNS-BIND9

and then execute following script

sudo sh ./adsblocker.sh

Above script will might take some time to finish it’s execution.

That’s it, Done :)

Now, we just need to verify if everything is working fine or not, for that just copy your EC2 instance’s public IP

Then, execute following command,

nslookup www.beginads.com 13.213.21.49

Here replace 13.212.142.132 with your public IP and execute it.

It should give result like below

If you are getting result like above, then you are good to go.

Now, you can use your public IP as a Ads blocker DNS. You can set this DNS in your router or in your mobile phone.

Thanks :)

--

--

Siddhpura Amitkumar

📱 Android Engineer, 📝 Writer, 💻 Open Source Contributor, Techie, IoT, Interactive Projects, ☁ AWS, Google Cloud, Firebase, Python, React.