[Dnsmasq-discuss] [PATCH] Reimplement rev-server to support arbitrary IPv4 prefix lengths

Dominik dl6er at dl6er.de
Tue Apr 14 19:26:09 BST 2020


Hey Simon,

I recently noticed that the "--rev-server" option is limited to 8, 16,
24, and 32 bit prefixes for IPv4 addresses. Since I needed support for
22 bit subnets in the network I'm currently setting up, I decided to
extend dnsmasq to support arbitrary IPv4 prefix-lengths. This mail has
three patches attached that contain my changes. I hope this is helpful
and can be merged into upstream dnsmasq.

Patch 1 implements support for arbitrary IPv4 prefixes by largely
rewriting option.c:add_rev4() and option.c:add_rev6()

Patch 2 adds error checking for IPv6 prefix-lengths as the current
algorithm only makes sense in 4 bit steps. As 4 bit steps in 128 bit
wide addresses seems sufficient to me, I didn't change the nice and
short algorithm used here.

Patch 3 adds logging for the inner details of what rev-server is doing.
It is an entirely optional patch. However, I would still recommend
adding it as it facilitates understanding of what the rev-server option
actually does (and if it does what the user is thinking it should be doing).

Exemplary log outputs:

./dnsmasq --rev-server=10.0.3.10/22,10.0.0.1
>>> dnsmasq[29637]: rev-server 10.0.3.10/22: address-to-name queries for
10.0.0.0 to 10.0.3.255 are sent to 10.0.0.1

./dnsmasq --rev-server=10.0.3.10/17,10.0.0.1#5353
>>> dnsmasq[29662]: rev-server 10.0.3.10/17: address-to-name queries for
10.0.0.0 to 10.0.127.255 are sent to 10.0.0.1#5353

./dnsmasq --rev-server=fe80::3aea:a711:fea1:2101/64,10.0.0.1
>>> dnsmasq[29667]: rev-server fe80::3aea:a711:fea1:2101/64:
address-to-name queries for fe80::3a00:0:0:0 to
fe80::3aff:ffff:ffff:ffff are sent to 10.0.0.1

(the displayed IPv6 addresses try to be as short as possible)

Best regards,
Dominik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Add-explanatory-log-message-to-rev-server-to-facilit.patch
Type: text/x-patch
Size: 5528 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20200414/c4514b02/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Check-for-valid-prefix-length-in-IPv6-rev-server-set.patch
Type: text/x-patch
Size: 978 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20200414/c4514b02/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-support-for-arbitrary-IPv4-prefix-lengths-in-rev.patch
Type: text/x-patch
Size: 8419 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20200414/c4514b02/attachment-0005.bin>


More information about the Dnsmasq-discuss mailing list