What's new

How to change NextDNS rewrite into dnsmasq address entry?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

XIII

Very Senior Member
I'm trying to change my NextDNS rewrite (router.mydomain.com to 192.168.1.1) into a dnsmasq entry (which I believe makes more sense, since it will work locally only anyway).

This is what I added in /jffs/configs/dnsmasq.conf.add:
Code:
address=/router.mydomain.com/192.168.1.1

This is what I added in /jffs/nextdns/nextdns.conf.add (see here):
Code:
forwarder mydomain.com=192.168.1.1

Then I executed this:
Code:
nextdns restart
service restart_dnsmasq

However:
Code:
➜ nslookup router.mydomain.com
Server:    45.90.28.35
Address 1: 45.90.28.35 dns1.nextdns.io

nslookup: can't resolve 'router.mydomain.com'

What am I doing wrong? How can I fix it?

(Once fixed I also want to "rewrite" homebridge.mydomain.com to 192.168.1.123 using an extra line in nextdns.conf.add)
 
Last edited:
Where are you running the nslookup? Router or client? Router will use WAN DNS by default, not dnsmasq. If it was from a client, then DHCP DNS must be set to NextDNS instead of router IP (or blank).
 
I executed nslookup on the router, but it does not work on a Raspberry Pi either...

Code:
(@pi) ➜ nslookup router.mydomain.com
Server:        192.168.1.1
Address:    192.168.1.1#53

Name:    router.mydomain.com
Address: 192.168.1.1
** server can't find router.mydomain.com: REFUSED

My router runs the NextDNS CLI and has this in the configuration file as well (with home.lan being my local network, configured in my router):

Code:
forwarder home.lan=192.168.1.1

A lookup (on the Pi) does work for other entries defined by dnsmasq:

Code:
(@pi) ➜ nslookup homey
Server:        192.168.1.1
Address:    192.168.1.1#53

Name:    homey.home.lan
Address: 192.168.1.121

(@pi) ➜ nslookup homey.home.lan
Server:        192.168.1.1
Address:    192.168.1.1#53

Name:    homey.home.lan
Address: 192.168.1.121

PS: a lookup of the Pi, on the router, seems to work:

Code:
(@router) ➜ nslookup pi
Server:    45.90.28.35
Address 1: 45.90.28.35 dns1.nextdns.io

Name:      pi-hb
Address 1: 192.168.1.122 pi.home.lan
 
Last edited:
What firmware version? dnsmasq 2.86 has been problematic due to the rewrite of the server and address handling. There have been quite a few unreleased bug fixes to-date.

If your address statement works in dnsmasq, then nextdns should never see the query. If it doesn’t work and it forwards upstream to nextdns, you might get in a forwarding loop.
 
I see this in the hosts file:

Code:
192.168.1.1 router.asus.com

I also expected this:
Code:
192.168.1.1 router.mydomain.com

However, that's not there.

Is my expectation wrong?

EDIT: If I add that line manually, the nslookup works. I thought the dnsmasq.conf.add should take care of this?
 
I see this in the hosts file:

Code:
192.168.1.1 router.asus.com

I also expected this:
Code:
192.168.1.1 router.mydomain.com

However, that's not there.

Is my expectation wrong?

EDIT: If I add that line manually, the nslookup works. I thought the dnsmasq.conf.add should take care of this?
dnsmasq.conf.add adds lines to dnsmasq.conf. hosts.add would append hosts entries to hosts.
 
Tried it without the NextDNS client?
 
Just to add another data point, on dnsmasq 2.85 on my OpenWrt router, if I add address=/router.mydomain.com/192.168.1.1 to the dnsmasq configuration, it resolves just fine from a client. So I’m still suspicious that 2.86 has broken something.

But the hosts file method should work instead.
 
Just to add another data point, on dnsmasq 2.85 on my OpenWrt router, if I add address=/router.mydomain.com/192.168.1.1 to the dnsmasq configuration, it resolves just fine from a client. So I’m still suspicious that 2.86 has broken something.
Just tested that on my router and it works fine.
 
I tried the hosts.add file instead and that works for me (even without the forwarder line in the NextDNS config file).

If I find some spare time I might test the dnsmasq.conf.add solution again, but if it’s a user error I might never find out the root cause… ;)
 
I tried the hosts.add file instead and that works for me (even without the forwarder line in the NextDNS config file).

If I find some spare time I might test the dnsmasq.conf.add solution again, but if it’s a user error I might never find out the root cause… ;)
Is there anything else in dnsmasq.conf.add related to mydomain.com? Anything that could conflict?
 
This is the only line in /jffs/configs/dnsmasq.conf.add before I started experimenting:

Code:
dhcp-option=lan,42,192.168.1.1 # ntpMerlin
 
I tried dnsmasq.conf.add instead of hosts.add again and now it works (on clients only), so I guess it was a user error earlier today after all... :oops:

The difference I observed so far is that via dnsmasq.conf.add the mapping only works on clients, but via hosts.add the mapping works for clients and the router itself.

Besides that, is there any reason I should prefer one approach above the other?
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top