Many advanced users of Xiaomi routers have encountered the term dnsmasq in logs, configuration files, or when installing alternative firmware. It's not just an abstract process, but a critical component that keeps your home network running. Understanding how it works solves device connectivity problems and speeds up domain response.
In standard Xiaomi firmware, such as MiWiFi or global versions, this service is often hidden from the userβs eyes, running in the background. 3G or AX3600 They get complete control of the parameters of the device, and that's where the answer to why some devices don't get it is. IP-Why the Internet is not working after the change DNS.
In this article, we will examine the role of this demon in the router ecosystem, how to configure it correctly for stable operation, and what typical mistakes enthusiasts make when modifying the system.
What is dnsmasq and why does a router need it?
Dnsmasq is a lightweight server that provides services. DNS (Domain Name System and DHCP (Dynamic Host Configuration Protocol for computer networks. In the context of Xiaomi routers, it acts as an intermediary between your gadgets and the global Internet. When you enter a website address in a browser, this component requests it. IP-address with the provider or cache it to speed up access.
The main objective of the program is distribution IP-Addresses to connected devices. DHCP-If you have a server built into dnsmasq, your smartphone or laptop simply cannot get a digital ID on the LAN, it's a fundamental mechanism without which building a LAN is impossible.
The second important function is caching. DNS-The router remembers the addresses of frequently visited sites, which allows devices on the network to open pages faster, since the request does not need to be sent to the provider every time.
- π Distribution of unique IP-Addresses to each connected device on the local network.
- β‘ Caching DNS-Requests to speed up the loading of web pages on all gadgets.
- π‘οΈ Blocking Ads and Trackers at the Router Level by Redirecting Requests.
It is worth noting that in the factory firmware Xiaomi functionality is often stripped down. the user sees only the basic DNS settings in the interface, while the real configuration file /etc/dnsmasq.conf remains unavailable without obtaining root rights or installing Telnet.
The role of dnsmasq in OpenWrt and Padavan firmware
When you install alternative operating systems like OpenWrt or Padavan, dnsmasq becomes a fully customizable tool. Unlike stock firmware, where the logic of the work is rigidly set by the manufacturer, here you can manage every aspect: from the time of renting to the time of renting. IP-addresses to the list of static mappings.
In an OpenWrt environment, a configuration is usually broken down into logical blocks in a file. /etc/config/dhcp. This makes management more structured, so you can create separate address pools for the guest network, or you can set up different addresses. DNS-servers VLAN. This gives you flexibility not available in standard Xiaomi solutions.
β οΈ Note: When editing dnsmasq configuration files in OpenWrt, a single syntax error can cause the router to stop handing out. IP-Always back up the file before making changes.
Padavan firmware, popular with older Xiaomi models (such as Mi Router 3 or 4A), uses its config format, often based on the original dnsmasq, but with additional scripts to integrate with the web interface. Here, settings are often applied through the graphical interface, but understanding the underlying processes helps in debugging.
A key advantage of using alternative firmware is the ability to connect plugins that extend the functionality of dnsmasq. For example, you can implement a parental control system or filter content without installing additional heavy software.
DHCP Setup: IP Rental and Static Addresses
One of the main functions of dnsmasq is to manage the address pool. By default, the router distributes addresses in a certain range, for example, from 192.168.31.2 to 192.168.31.254.
For stationary devices such as printers, NAS or security cameras, it is critical to use static cameras IP-Dnsmasq allows you to link MAC-device address IP. This ensures that your printer will always be available at the same address, even after the router is restarted.
The static binding setting in the configuration file is as follows. MAC-target device address, desired IP And optionally, it's rent time, so you don't have to set up statics on each device separately.
dhcp-host=AA:BB:CC:11:22:33,192.168.31.50,printer,12hOn this line AA:BB:CC:11:22:33 β it MAC-address, 192.168.31.50 - fixed IP, printer is the host name and 12h β This record ensures the stability of network services.
βοΈ Static adjustment IP
If you change the DHCP range, make sure that static addresses donβt fall into the dynamic part of the pool to avoid address conflicts.
DNS management and advertising blocking
In addition to giving out addresses, dnsmasq is actively used to filter traffic. Mehm is simple: you create a list of domains that you want to block (for example, ad networks), and instruct dnsmasq to forward requests to them to a local address 127.0.0.1 or 0.0.0.0.
This allows you to block ads on all devices on the network, including Smart TVs and apps on phones where you can not install a blocker. Domain lists (hosts files) can be very large, but dnsmasq works with them effectively thanks to an optimized data structure.
| Parameter | Description | Example of meaning |
|---|---|---|
| server | Address of the higher DNS server | 8.8.8.8 |
| address | Redirecting the domain to IP | /doubleclick.net/127.0.0.1 |
| no-resolv | Ignore DNS from /etc/resolv.conf | true |
| log-queries | Log all DNS requests | true |
Using third-party DNSs, such as Google DNS (8.8.8.8) or Cloudflare (1.1.1.1), via dnsmasq can speed up network response if the provider provides slow name servers. However, it is worth remembering that some local service providers (IPTV, personal accounts) may become unavailable.
β οΈ Attention: Enable logging of all DNS-Log-queries can quickly fill up space on the router's flash memory, and use this option only for short-term problems diagnosis.
Typical errors and diagnosis of problems
The most common problem after setting up β devices stop receiving IP-This usually means that the dnsmasq process has fallen or the configuration file contains a syntactic error (/var/log/messages syslog, or syslog, you can find lines like "failed to load names from..." that indicate a problem.
Another common situation is DNS leakage. This occurs when dnsmasq is configured incorrectly and redirects requests to local domains (.local,.lan) to an external network where they cannot be resolved, which leads to the inability to open the router's web interest by name.
How to restore access if DNSMASQ has blocked the network?
To diagnose, use the nslookup or dig utility on the client device, and they'll show you which one. DNS-The server responds to requests and which IP If you see an address of 0.0.0.0 for a normal site, it means that the lock has worked.
It is also worth checking whether the router is running the second. DHCP-server (e.g., from odhcpd) that can conflict with dnsmasq. OpenWrt uses odhcpd by default, and dnsmasq can only be configured as cache DNS, Which often causes confusion among beginners.
π‘
Use the command "ps | grep dnsmasq" in the router terminal to make sure the process is running and running with the correct configuration file.
Optimization of productivity and safety
On weak devices like the Xiaomi Mi Router 3 with 128MB of memory, a large list of blocked domains can consume a significant portion of RAM. Dnsmasq loads lists in RAM at start. If memory is scarce, the process can be completed by the system (OOM Killer), which will bring down the network.
To optimize, you should use only the necessary lock lists and update them regularly, and you can limit the size of the DNS cache to the cache-size parameter. Reducing the cache will free up memory, but can slightly reduce the speed of revisiting sites.
In security matters, it is important to restrict access to dnsmasq. The server should not be accessed from an external network (WAN). Make sure that the firewall settings ports 53 (UDP/TCP) closed to external connections. DNS-The solution can be used by attackers for DDoS attacks.
π‘
Dnsmasq is a balance between functionality and resource consumption. Routers with a low RAM (less than 64 MB) should not use huge ad blocking lists.
Regular updates of firmware or dnsmasq packages in OpenWrt are important, since vulnerabilities are periodically found in this software that allow you to execute malicious code through a specially formed code. DNS-request.