Enforce the use of only local nameservers for certain public domains

I have a domain rozhur.me. I need rpi.rozhur.me to always resolve to 192.168.124.10 on my local network, and to resolve to public IP on other networks.

I achieved this using the option option address '/rpi.rozhur.me/192.168.124.10' in /etc/config/dhcp

The problem is that dnsmasq resolves both through local name servers and ISP name servers, as a result, local DNS records are mixed with public ones.

Example:

$ host rpi.rozhur.me
rpi.rozhur.me has address 192.168.124.10
rpi.rozhur.me is an alias for rozhur.me.
rpi.rozhur.me is an alias for rozhur.me.
rozhur.me mail is handled by 10 mx1.rozhur.me.

Sometimes it shows the public IP instead of the local IP if you resolve in advance another domain from *.rozhur.me that does not have a local host override.

I need it to always be like this when I resolve it on my local network:

$ host rpi.rozhur.me
rpi.rozhur.me has address 192.168.124.10

How to achieve this?

Change option to list and remove the rpi subdomain.

list address '/rozhur.me/192.168.124.10'

Thus, rozhur.me and all possible subdomains will be resolved to 192.168.124.10.

To ensure that rozhur.me will only be resolved locally, (just in case) add :

list server '/rozhur.me/127.0.0.1'
1 Like