1

I would like, in my network, the host 10.10.10.1 to resolve names via 8.8.8.8 and 10.10.10.2 via 8.8.4.4. 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/8.8.8.8 which would redirect to 8.8.8.8 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

1

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

2
  • 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
    Commented Jun 11, 2016 at 16:30
  • I gave up and moved to bind - the setup for this functionality was a breeze.
    – WoJ
    Commented Jun 19, 2016 at 19:16
1

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.

dhcp-mac=set:alt,00:03:aa:bb:cc:dd
dhcp-option=6,8.8.8.8,8.8.4.4
dhcp-option=alt:6,8.8.4.4,8.8.8.8

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

2
  • 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
    Commented 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
    Commented Jun 11, 2016 at 17:26
0

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 .