OpenWrt uses its own Dnsmasq to block websites (set resolution)

2019-08-02

Sometimes, we may want to block a website (for example, to block Xiaomi ads), or set a resolution for a specific website (for example, to test our website locally before publishing). OpenWrt provides a parsing tool Dnsmasq, which is much more powerful than the local host. Compared with the local host, it supports wildcarding and can parse special types of records.

This article is migrated from the old blog. The original link is https://lookas2001.com/openwrt-%e4%bd%bf%e7%94%a8%e8%87%aa%e5%b8%a6%e7%9a%84 -dnsmasq-%e5%b1%8f%e8%94%bd%e7%bd%91%e7%ab%99%ef%bc%88%e8%ae%be%e7%bd%ae%e8%a7%a3%e6%9e%90%ef%bc%89/

There are online tutorials, and you need to install adblock or something, but it is actually a one line (three lines to be exact) command (luci does not provide the location for modification, so it cannot be solved on the web page).

 #Set example.com domain name a type record to 192.168.0.1 uci add_list dhcp.@ dnsmasq[0].address= "/example.com/192.168.0.1"
 #A type resolution of shielding ad.mi.com domain name
 # uci add_list dhcp.@ dnsmasq[0].address="/ad.mi.com/"
 #Effective configuration (written to/etc/config/dhcp) uci commit dhcp #Restart service service dnsmasq restart

Ref

Maintenance of the website requires a certain amount of expense. If you agree with this article, please close the advertisement blocker and browse the advertisement. Thank you!
Loading

(∀) In other words, welcome to the small station of lookas!

This is the place where lookas records some things. From time to time, there may be some magical brain holes or unreliable ideas of lookas.

Anyway, let's have a look.