DNS Ad Blocking is done Via A DNS sinkhole, which is also known as Blackhole DNS , It’s basically DNS server that gives out false information to prevent the use of a domain name.
Whenever request is made from your browser, It’s first checked with your Client hosted DNS server,
One Of such Server is Pi-hole (It’s Linux based Server which worked with Rasberry Pi.)
Client hosted DNS server is basically DNS server which contain list of domains which usually serve the ads.
Client hosted DNS Sever Block Over 1.6 Million Ad-serving domains known to serve advertisements can be blocked before they even reach your computer. The list of these domains are maintained by different sites across the Internet
DNS Ad blocking is done via Hardware mostly, since it require Hardware which can work intermediate between Actual domain and your website.open dns also help in ad blocking.
For Example:
When you load the site, Ad request will be made from the site (https://googleads.g.doubleclick.net),
And Client Hosted DNS Server already include http://googleadsyndication.com in DNS blocklist.
Client level DNS will check with existing Ad serving blocklist, since this domain name will be present, It will not send request to https://googleads.g.doubleclick.net, The Ad Request Will be redirected to Client DNS, Which then will not call any Server.
If no request is sent to Ad serving domain, Nothing will be return and no ads will be served.
so the real server is never contacted. This can not only speed up your Web browsing, but it will also reduce your bandwidth usage because your browser is not downloading the ad from the server.
There are multiple paid and free options available to block the ads from serving.