0

I'd like to give unknown clients an ip address in one range and known clients in another (that is a static one).

I tried quite a lot now and don't seem to get it working. All I get is an "no address available" error.

My network is 10.1.0.0/22 (<-!!!) Guests should be assigned an address in the range 10.1.3.1-10.1.3.254 Static addresses are in range 10.1.2.1-10.1.2.254

so this is my config:

iface eth0 inet static
    address 10.1.0.2/22
    gateway 10.1.0.1

eth0@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.1.0.2/22 brd 10.1.3.255 scope global eth0
        valid_lft forever preferred_lft forever

and

dhcp-range=tag:guests,10.1.3.1,10.1.3.254,255.255.252.0,12h
dhcp-range=tag:known,10.1.2.0,static,24h
dhcp-option=option:router,10.1.0.1
dhcp-option=option:dns-server,10.1.0.3
dhcp-option=option:ntp-server,10.1.0.1

dhcp-host=aa:bb:cc:dd:ee:ff,10.1.2.1
dhcp-host=11:22:33:44:55:66,10.1.3.2

Known hosts are given their addresses (regardless if its a .2. or .3. address) but unknown dont get anything.

Scheintod
  • 391
  • 1
  • 5
  • 17

3 Answers3

0

You're not giving a netmask for the tag:known range, so dnsmasq will assume it's the entire /22, completely covering the tag:guests range.

  • Thanks for your answer. How would I do that? All my tries like: ```dhcp-range=tag:known,10.1.2.0,255.255.255.0,static,24h``` or ```dhcp-range=tag:known,10.1.2.1,10.1.2.254,255.255.255.0,static,24h``` result in dnsmasq not even starting. (bad dhcp-range at line 2 of /etc/dnsmasq.d/dhcp) – Scheintod Nov 11 '21 at 19:00
  • try `dhcp-range=tag:known,10.1.2.1,static,255.255.255.0,24h` (this is just a hunch, unfortunately I'm not able to test it right now ;-)) –  Nov 11 '21 at 19:09
  • that does start but result (even in different 252/255 combinations) all in no address available :( – Scheintod Nov 11 '21 at 19:28
0

Seems the problematic part was: tag:known. For some reason dnsmasq doesn't show something different in startup log messages when I remove it but now seems to work. (I cant tell if it works with /22 because I stoped using it.)

Scheintod
  • 391
  • 1
  • 5
  • 17
0

To use a tag, it needs to be set somewhere. I do this for requests relayed from another subnet:

dhcp-range=set:wifi,192.168.4.0,static,255.255.255.0,24h
dhcp-option=tag:wifi,option:router,192.168.4.1

In the OP's case the dhcp-host entry would be the place to set the known tag, like this:

dhcp-host=aa:bb:cc:dd:ee:ff,10.1.2.1,set:known

However (from the dnsmasq manpage): When a host matches any --dhcp-host directive (or one implied by /etc/ethers) then the special tag "known" is set.

So that set:known is implicit. Using ! to negate that tag, we can apply a different range to 'unknown' hosts:

dhcp-range=tag:!known,10.1.3.1,10.1.3.254,255.255.252.0,12h
dhcp-range=tag:known,10.1.2.0,static,255.255.252.0,24h
dhcp-option=option:router,10.1.0.1
dhcp-option=option:dns-server,10.1.0.3
dhcp-option=option:ntp-server,10.1.0.1

dhcp-host=aa:bb:cc:dd:ee:ff,10.1.2.1
dhcp-host=11:22:33:44:55:66,10.1.3.2