Dnsmasq tags and conditional DNS server

As a general solution, I would like to share dns resolution between different servers using dnsmasq.

i.e. By default, dns server A is used if dns server B is not explicitly installed on the host (mac).

I would like to split my network into dnsmasq subnets, for this example say:

192.168.1.80-150 = green

192.168.1.40-50 = red

I would like the dhcp lease to be passed using -default-tagged green, with the exception of a few specific MAC addresses where I would like to pass the red tag. I am sure that this part works successfully (I suppose), where I explicitly install it using the MAC - but what I need is all that is not specified otherwise - the default is green.

Then I would like to say "for all green tags, give them DNS A server as your resolver", "for all red tags, give them DNS server B as your resolver."

Is it possible?

I have the following configuration, which does not seem to work:

--8<--
dhcp-range=set:green,192.168.1.80,192.168.1.150,infinite
dhcp-range=tag:red,192.168.1.40,192.168.1.50,infinite

dhcp-option=net:green,option:dns-server,8.8.8.8,8.8.4.4
dhcp-option=net:red,option:dns-server,192.168.1.11    

dhcp-host=AA:BB:CC:DD:CC:BB,redhost1,192.168.1.41,infinite,net:red
dhcp-host=BB:CC:DD:AA:BB:00,greenhost1,192.168.1.81,infinite,net:green

dhcp-option=option:router,192.168.1.1
--8<--

This does not seem to work, I have different hosts that are assigned different IP addresses based on whether I match their MAC, and then it seems that the dns server is being distributed incorrectly.

I believe that the dns server is not being transmitted because "cat / etc / resolv.conf" on one of the hosts shows 127.0.0.1.

To summarize my queries:

  • Can I make everything default “green” if I don't explicitly specify “red” by MAC (at the moment I have to explicitly put all the Macs in a conf file)?
  • Can I specify different DNS servers for different labeled networks?
  • , "" "", googling , .

+4
1

ok, ( ), , , - .

, DNS (, , gw) , , , :

dhcp-range=set:green,192.168.1.80,192.168.1.150,infinite

# red network
dhcp-host=11:22:33:44:55:66,hosta,192.168.1.11,infinite,set:red
dhcp-host=66:55:44:33:22:11,aa:bb:cc:dd:ee:ff,hostb,192.168.1.12,infinite,set:red

# green network mobile
dhcp-host=dd:dd:dd:dd:dd:dd,android1,192.168.1.21,infinite,set:green
dhcp-host=cc:cc:cc:cc:cc:cc,android2,192.168.1.22,infinite,set:green

, . MAC- . , DNS gw, :

# options
dhcp-option=tag:green,option:dns-server,192.168.1.1,192.231.a.b   # ,8.8.8.8,8.8.4.4
dhcp-option=tag:red,option:dns-server,192.168.1.c
dhcp-option=tag:green,option:router,192.168.1.1
dhcp-option=tag:red,option:router,192.168.1.c

/, , net/set/tag:

  • : - , , dhcp . "tag:", . , .
  • dhcp-host ( , "set:" )
  • , "net:" "tag:" "set:" . ( dhcp-host, "set:" "net:".) #! '#' NOT.

:

  • set tag ( )
  • dhcp dhcp-host,
  • , .
  • dhcp-, mac, eth0 wlan mac .

, , , -.

+8

Source: https://habr.com/ru/post/1532224/


All Articles