[Dnsmasq-discuss] Change upstream server by client?

Michael Smith michael at kmaclub.com
Thu Dec 22 20:46:53 UTC 2022


On 12/18/22 09:10, Jonathan Stafford wrote:
> Thanks, Michael.  That will work to get them using that server, but 
> it's totally bypassing dnsmasq which means my local entries from 
> /etc/hosts don't resolve.  I'd like both things to work to be difficult :)


Hi Jonathan,


Sorry, I didn't respond earlier, but here is what I do in more detail.


I run 2 instances of pihole (DNSmasq) on docker.   Each run on their own 
IP address (macvlan) separate from the docker host. Their IP addresses 
are .2 and .3.


The .2 host is primary and forwards upstream to 1.1.1.1.   This 
container also holds all the hosts file info and handles DHCP+dynamic 
host DNS resolution.

The .3 host is secondary and handles only DNS requests for the kids.   
This forwards upstream to 1.1.1.3.    If  a DNS request comes in for 
local domain info, it simply forwards those requests to .2 like this:

server=/mydomain.com/192.168.101.2
server=/101.168.192.in-addr.arpa/192.168.101.2


Combine with the tagging and now you can point any client to either 
upstream DNS:

# Define DNS servers
dhcp-option=option:dns-server,192.168.101.2
dhcp-option=tag:kidsdevices,option:dns-server,192.168.101.3

dhcp-host=0c:51:01:95:d3:36,set:kidsdevices   # Ipad
dhcp-host=58:41:4E:CD:D2:0A,set:kidsdevices   # Iphone


While I did this with Pihole, you can easily do this with DNSmasq 
only.    This is also similar to what Geert was suggesting.


Michael




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20221222/395217bc/attachment.htm>


More information about the Dnsmasq-discuss mailing list