Skip to content

Commit 21c23e7

Browse files
authored
Merge pull request #14 from tuanductran/copilot/add-dnsmasq-integration-rule
2 parents c8e6d09 + 66d448a commit 21c23e7

2 files changed

Lines changed: 113 additions & 0 deletions

File tree

skills/integrations/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ metadata:
1313

1414
| Rule | Keywords | Description |
1515
|------|----------|-------------|
16+
| [DNSMasq Integration](rules/dnsmasq-integration.md) | dnsmasq, dns, router, client reporting, conditional configuration, port configuration, setup-router | Configure DNSMasq and NextDNS to run together while maintaining client reporting and conditional configuration features |
1617
| [Public DNS and AdGuard Home Integration](rules/public-dns-and-adguard.md) | public dns, adguard, anycast, doh, dot, browser setup, windows, android, ios, upstream dns, bootstrap dns | Configure NextDNS public DNS servers on browsers and operating systems, and integrate with AdGuard Home as upstream DNS provider |
1718
| [OpenWrt Integration](rules/openwrt.md) | openwrt, router, installation, upgrade, troubleshooting, ssh, luci | Installation, upgrade, and troubleshooting guidance for NextDNS on OpenWrt routers |
1819

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: DNSMasq Integration
3+
impact: MEDIUM
4+
impactDescription: Running DNSMasq alongside NextDNS without proper configuration can result in loss of client reporting and conditional configuration features. This guidance ensures both services work together seamlessly while maintaining full NextDNS functionality.
5+
type: capability
6+
tags: dnsmasq, dns, router, client reporting, conditional configuration, port configuration, setup-router
7+
---
8+
9+
# DNSMasq Integration
10+
11+
**Impact: MEDIUM** - Enables DNSMasq and NextDNS to run together while preserving client reporting and conditional configuration capabilities
12+
13+
## Overview
14+
15+
DNSMasq is a lightweight DNS forwarder commonly bundled with router firmwares. It is possible to run DNSMasq and NextDNS together on the same system while maintaining full NextDNS functionality, including client reporting and conditional configuration features.
16+
17+
This integration allows DNSMasq to continue handling local DNS resolution and DHCP services while forwarding external DNS queries to NextDNS for filtering and protection.
18+
19+
## Configuration Steps
20+
21+
### Step 1: Configure NextDNS to Listen on Alternative Port
22+
23+
NextDNS must be configured to listen on a different port to avoid conflicts with DNSMasq, which typically uses port 53.
24+
25+
```bash
26+
# Configure NextDNS to listen on port 5555 on localhost
27+
nextdns install -listen 127.0.0.1:5555
28+
```
29+
30+
This configuration ensures NextDNS binds to port 5555 instead of the default port 53, allowing DNSMasq to continue operating on port 53.
31+
32+
### Step 2: Configure DNSMasq to Forward to NextDNS
33+
34+
Add the following parameters to your DNSMasq configuration to forward DNS queries to NextDNS while preserving client information:
35+
36+
```conf
37+
# Forward DNS queries to NextDNS on port 5555
38+
--server=127.0.0.1#5555
39+
40+
# Include client MAC address in DNS queries
41+
--add-mac
42+
43+
# Include client subnet information (IPv4: /32, IPv6: /128)
44+
--add-subnet=32,128
45+
```
46+
47+
These parameters ensure that:
48+
49+
- `--server=127.0.0.1#5555`: All DNS queries are forwarded to NextDNS running on port 5555
50+
- `--add-mac`: Client MAC addresses are included in DNS queries, enabling device identification
51+
- `--add-subnet=32,128`: Client subnet information is added for IPv4 (/32) and IPv6 (/128), supporting conditional configuration
52+
53+
## Automatic Configuration for Router Firmwares
54+
55+
On router firmwares that ship with DNSMasq pre-installed, the above configuration can often be handled automatically.
56+
57+
When running NextDNS installation on such routers, use the `-setup-router` parameter:
58+
59+
```bash
60+
# Automatic router setup (handles DNSMasq configuration)
61+
nextdns install -setup-router
62+
```
63+
64+
The `-setup-router` flag automatically detects DNSMasq and configures both services to work together without manual intervention. This is the recommended approach for router environments.
65+
66+
## Best Practices
67+
68+
- **Use alternative port**: Always configure NextDNS to use a non-standard port (e.g., 5555) when running alongside DNSMasq
69+
- **Preserve client information**: Ensure `--add-mac` and `--add-subnet` parameters are set to maintain client reporting features
70+
- **Prefer automatic setup**: On router firmwares, use `-setup-router` parameter for automatic configuration
71+
- **Verify forwarding**: Test DNS resolution after configuration to ensure queries are properly forwarded to NextDNS
72+
- **Check logs**: Monitor both DNSMasq and NextDNS logs to verify proper operation and client identification
73+
74+
## Troubleshooting
75+
76+
### Port Conflicts
77+
78+
If you encounter port binding errors, verify that:
79+
80+
- DNSMasq is running on port 53
81+
- NextDNS is configured to use an alternative port (e.g., 5555)
82+
- No other services are using the chosen alternative port
83+
84+
```bash
85+
# Check which service is using port 53
86+
netstat -tulpn | grep :53
87+
88+
# Verify NextDNS is listening on the configured port
89+
netstat -tulpn | grep :5555
90+
```
91+
92+
### Client Reporting Not Working
93+
94+
If client devices are not appearing correctly in NextDNS analytics:
95+
96+
- Verify `--add-mac` parameter is enabled in DNSMasq configuration
97+
- Check that `--add-subnet` parameter is properly configured
98+
- Ensure DNS queries are being forwarded to NextDNS (check DNSMasq logs)
99+
100+
### Router Firmware Issues
101+
102+
If `-setup-router` fails or doesn't configure properly:
103+
104+
- Fall back to manual configuration using Steps 1 and 2
105+
- Check router firmware documentation for DNSMasq configuration location
106+
- Ensure you have appropriate permissions to modify DNSMasq configuration
107+
108+
## Reference
109+
110+
- [NextDNS CLI Wiki](https://github.com/nextdns/nextdns/wiki)
111+
- [DNSMasq Documentation](https://thekelleys.org.uk/dnsmasq/doc.html)
112+
- [NextDNS Setup Guide](https://help.nextdns.io)

0 commit comments

Comments
 (0)