This will show you how to use your EdgeRouter as a local DNS server and blocking DNS queries to domains that hosts ads and malware. An alternative is to use Pi-hole, which gives many features such as web UI, statistics, DNS-over-HTTPS, and possibly better written code ;)
The blocklists used are: