[Dnsmasq-discuss] dhcp-range for DNS entries: how to gain A and AAAA for same host?

Steffen Nurpmeso steffen at sdaoden.eu
Mon Mar 15 19:35:44 UTC 2021


Hello.

Geert Stappers wrote in
 <20210314095043.5ctepkik2e66xjrz at gpm.stappers.nl>:
 |On Sun, Mar 14, 2021 at 01:39:18AM +0100, Steffen Nurpmeso via Dnsmasq-d\
 |iscuss wrote:
 |> For being more automatic and flexible with (many) VMs i changed
 |> from a static addn-hosts= to a dhcp-hostsfile= approach, which
 |> luckily can still serve as the sole DNS source for already
 |> assigned IPs for all already existing VMs (slowly to be migrated
 |> to DHCP-based addresses, if at all), which is great!
 |> (Of course, this time only when the VM is running, but this does
 |> not really matter here.)
 |> 
 |> However, i stumbled over a problem on Linux.  If i scp a file with
 |> the name of the VM it tooks a long time, and this is because ssh
 |> uses getaddrinfo, and the GNU C library resolver sends out queries
 |> for A and AAAA at the same time.  The A is delivered quickly by
 |> dnsmasq, but the AAAA one is forwarded (thus subject to fail, on
 |> dotless names).
 |
 |That reminds on new dnsmasq feature of replying with NODATA
 |Visit https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2021q1/0\
 |14779.html
 |to read more about it.

In a way, yes.  However my problem is more simple as it would
vanish by going back to static hosts.txt assignment, this is where
i am coming from.

 |> So i wondered how to add IPv6 support for this config in order to
 |> let dnsmasq simply serve the AAAA in addition, anyway a goal, to
 |> finally relearn, and this time for good, about IPv6.  (I even
 |> "own" an unbelievable amount of them for a time.  Could be used
 |> for something.  Anyhow.)
 |> And this turned out to be impossible.  First i simply changed
 |> a line in the hosts.dnsmasq (this last of some trials)
 |> 
 |>   54:72:01:01:00:15,alp-2021,10.0.1.21,[::5472:101:15]
 |> 
 |> but that turned out not to serve, so, understandable that,
 |> i tried to add the IPv6 range to the dhcp-range= line of
 |> dnsmasq.conf, which was
 |> 
 |>   dhcp-range=10.0.0.1,10.3.255.253,255.252.0.0,24h
 |> 
 |> until then.  This seems not to work, so i added another
 |> 
 |>   #dhcp-range=3fb:1::5472:101:1,3fb:1::5472:104:FFFF,24h
 |> and
 |>   #dhcp-range=::1,constructor:vm,24h
 |> 
 |> at least the latter worked, but now we _only_ had IPv6 in the VM,
 |> and the IPv4 address was not assigned.
 |
 |Not knowning how much iterations it went through,
 |but I hope that
 |
 |   dhcp-range=10.0.0.1,10.3.255.253,255.252.0.0,24h
 |   dhcp-range=3fb:1::5472:101:1,3fb:1::5472:104:FFFF,24h
 |and
 |   dhcp-range=10.0.0.1,10.3.255.253,255.252.0.0,24h
 |   dhcp-range=::1,constructor:vm,24h
 |where tried.  Yes, two  dhcp-range lines in the same file.
 |One for IPv4 the other for IPv6.

Well yes multiple entries each time.  But it does not matter.

  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 client provides name: alp-2021
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 DHCPREQUEST(vm) 10.0.1.21 54:72:01:01:00:15
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 tags: known, vm
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 DHCPACK(vm) 10.0.1.21 54:72:01:01:00:15 alp-2021
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 requested options: 1:netmask, 3:router, 6:dns-server, 12:hostname,
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 requested options: 15:domain-name, 28:broadcast, 42:ntp-server
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 next server: 10.0.0.1
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  1 option: 53 message-type  5
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  4 option: 54 server-identifier  10.0.0.1
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  4 option: 51 lease-time  1d
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  4 option: 58 T1  12h
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  4 option: 59 T2  21h
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  4 option:  1 netmask  255.252.0.0
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  4 option: 28 broadcast  10.3.255.255
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  4 option:  3 router  10.0.0.1
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  4 option:  6 dns-server  10.0.0.1
  Mar 15 20:04:02 kent dnsmasq-dhcp[27703]: 396513898 sent size:  8 option: 12 hostname  alp-2021
...
  Mar 15 20:05:11 kent dnsmasq[27703]: 10 127.0.0.1/22091 query[A] alp-2021 from 127.0.0.1
  Mar 15 20:05:11 kent dnsmasq[27703]: 10 127.0.0.1/22091 DHCP alp-2021 is 10.0.1.21
  Mar 15 20:05:11 kent dnsmasq[27703]: 11 127.0.0.1/22091 query[AAAA] alp-2021 from 127.0.0.1
  Mar 15 20:05:11 kent dnsmasq[27703]: 11 127.0.0.1/22091 forwarded alp-2021 to 10.5.0.2
  ...

 |> In theory this would not be such an issue, but of course the
 |> origin of why i tried to change it was the DNS forwarding of the
 |> C library resolver, and now i wonder what to do.
 |> 
 |> Is this a misconfiguration, or is there another way to support
 |> IPv4 + IPv6 DHCP, but especially DNS service for both address
 |> types for the same machine?
 |
 |a misconfiguration could be at client side.
 |DHCP client not telling it's hostname to the DHCP server
 |during the request.
 ...
 |Please report back

I now also tried to use parts of my real address range.  (I own
a full set of 64-bits of addresses, that is grazy.)  I no nothing
of IPv6, i wrote an InetAddress parser that hm was actually pretty
good (less devices suffixes) and configurable in 2003 i think, but
that was basically it, and almost nothing ever since.  But the
address range i now used is globally usable, too.

I mean, it is not really a problem, i can easily generate IPv6
entries from the hosts.dnsmasq, but the fun would now be to become
completely automatic, only storing the MAC and a name in that
file, or even generating as many as desired on the fly,
dynamically, and still being able to spin them up with dnsmasq,
after having reread the updated file, serving them properly via
DNS for IPv4 and/or (later maybe even tending for or) IPv6.

 |P.S.
 |Original poster might
 |deem https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2021q1/01\
 |4810.html
 |usefull.

For me it would be nice that if dnsmasq serves only IPv4 via DHCP
even though the hosts.dnsmasq has according entries for IPv4 and
IPv6, it would not forward the IPv6 query (and vice versa).
Forward looking it would be even better if there would be
a configuration option so that i would only create the MAC (and
a name), and it would still serve what is requested/taken but
still serves both entries via DNS.

Other than that it seems dnsmasq cannot do this for now?
It is great nonetheless :)

Ciao,

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



More information about the Dnsmasq-discuss mailing list