I would like, in my network, the host to resolve names via and via They receive their DNS settings via the dnsmasq DHCP service.

I can imagine two solutions:

  • the hosts get a specific set of DNS servers depending on their IP
  • both hosts resolve though the dnsmasq server (so they both receive its IP address as DNS server) and dnsmasq redirects the requests based on the source IP of the requesting host.

Is this something which is configurable in dnsmasq?

The closest configuration I found is server=/example.com/ which would redirect to requests to resolve example.com. In my case however, it is the source which should trigger the condition and not the destination.

3 Answers 3


Perhaps you should consider using the "views" feature in BIND. I'm not sure exactly what you're doing, but it sounds like you need different IP resolution inside of your LAN from outside of your LAN.

BIND allows you to respond to queries with different results based on the source IP. Read more about it here: https://kb.isc.org/article/AA-00851/0/Understanding-views-in-BIND-9-by-example.html

  • 1
    Thank you for the answer - I +1 it but I was looking for a solution with dnsmasq if possible (I was hoping for the equivalent of views, actually)
    – WoJ
    Jun 11, 2016 at 16:30
  • I gave up and moved to bind - the setup for this functionality was a breeze.
    – WoJ
    Jun 19, 2016 at 19:16

You can do this by assigning a class to one of the servers. Then based on that class send a different list of DNS servers. The setting below use the mac address to set a tag which is used to specify a different server list. There are various conditions that can be used to set a tag.


It would be simpler to just set the /etc/resolv.conf on one server to the appropriate value.

  • Thank you. Would you know if there is a mechanism in dnsmasq which would do the dispatching at the server level? (my second "solution", akin to the views in bind)
    – WoJ
    Jun 11, 2016 at 16:31
  • @Woj dnsmasq is a light-weight DNS/DHCP server. I haven't seen anything that would indicate is has anything similar to views. You could use two instances listening on different IP addresses.
    – BillThor
    Jun 11, 2016 at 17:26

you could use -p option in dnsmasq to run multiples instances of dnsmasq and redirect using iptables

some thing like this :

# dnsmasq -p 1054
# dnsmasq -p 1055
# iptables -I INPUT --src NET1/M --dst YOURIP -p udp --dport 53 -j REDIRECT --to-ports 1054
# iptables -I INPUT --src NET2/M --dst YOURIP -p udp --dport 53 -j REDIRECT --to-ports 1055

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .