Discussion:
[Dnsmasq-discuss] --synth-domain enhancement
Andy Hawkins
2018-01-23 09:25:12 UTC
Permalink
Hi,

I'm contemplating a move from bind and isc-dhcpd to dnamasq.

One of the features of bind that I take advantage of in my domain is
generating sequences of DNS entries using a single line. For example, in my
zone file I have:

$GENERATE 50-70 dyn-${-50} IN A 192.168.202.$

This will generate the following DNS entries:

dyn-0.gently.org.uk on address 192.168.202.50
dyn-1.gently.org.uk on address 192.168.202.51

...

dyn-19.gently.org.uk on address 192.168.202.69
dyn-20.gently.org.uk on address 192.168.202.70

I realise that dnsmasq has the 'synth-domain' option, but the names
generated by this are a little ugly. Is there any chance an enhancement
could be made to so something similar to the facilities available in bind?

Thanks

Andy
Simon Kelley
2018-02-14 23:22:35 UTC
Permalink
Post by Andy Hawkins
Hi,
I'm contemplating a move from bind and isc-dhcpd to dnamasq.
One of the features of bind that I take advantage of in my domain is
generating sequences of DNS entries using a single line. For example, in my
$GENERATE 50-70 dyn-${-50} IN A 192.168.202.$
dyn-0.gently.org.uk on address 192.168.202.50
dyn-1.gently.org.uk on address 192.168.202.51
...
dyn-19.gently.org.uk on address 192.168.202.69
dyn-20.gently.org.uk on address 192.168.202.70
I realise that dnsmasq has the 'synth-domain' option, but the names
generated by this are a little ugly. Is there any chance an enhancement
could be made to so something similar to the facilities available in bind?
It could be done: just requires even more scary string-mangling in
src/domain.c and inventing a way to configure it.

I prosose something like

--synth-domain=thekelleys.org.uk,192.168.0.0/24,internal-*

where the final * in the prefix generates "counting mode" so that

192.168.0.0 becomes internal-0,thekelleys.org.uk

A range rather than a subnet is already allowed, so your example becomes


--synth-domain=gently.org.uk,192.168.202.50,192.168.202.70,dyn-*


Anyone got a better idea?


Cheers,

Simon.
Andy Hawkins
2018-02-15 17:12:39 UTC
Permalink
Hi,
Post by Simon Kelley
It could be done: just requires even more scary string-mangling in
src/domain.c and inventing a way to configure it.
I prosose something like
--synth-domain=thekelleys.org.uk,192.168.0.0/24,internal-*
where the final * in the prefix generates "counting mode" so that
192.168.0.0 becomes internal-0,thekelleys.org.uk
A range rather than a subnet is already allowed, so your example becomes
--synth-domain=gently.org.uk,192.168.202.50,192.168.202.70,dyn-*
Anyone got a better idea?
That sounds good to me. The only thing missing is the 'arithmetic' bit on
the generated host name / IP address.

In your example above, I would want (for example)

192.168.202.50 - dyn-1
192.168.202.51 - dyn-2

etc.

This is possible in bind using the syntax I posted earlier, but isn't (yet)
in dnsmasq.

It's hardly the end of the world if I have to manually enter each one
though, so I wouldn't push for this change too much if it turned out to be
particularly difficult or generate any strong objections.

Andy
Simon Kelley
2018-02-16 15:01:23 UTC
Permalink
Post by Andy Hawkins
Hi,
Post by Simon Kelley
It could be done: just requires even more scary string-mangling in
src/domain.c and inventing a way to configure it.
I prosose something like
--synth-domain=thekelleys.org.uk,192.168.0.0/24,internal-*
where the final * in the prefix generates "counting mode" so that
192.168.0.0 becomes internal-0,thekelleys.org.uk
A range rather than a subnet is already allowed, so your example becomes
--synth-domain=gently.org.uk,192.168.202.50,192.168.202.70,dyn-*
Anyone got a better idea?
That sounds good to me. The only thing missing is the 'arithmetic' bit on
the generated host name / IP address.
In your example above, I would want (for example)
192.168.202.50 - dyn-1
192.168.202.51 - dyn-2
etc.
This is possible in bind using the syntax I posted earlier, but isn't (yet)
in dnsmasq.
My second example gives exactly that. To clarify, the serial numbers in
the names correspond to the addresses in the range supplied. If you use
a subnet to specify the range, for instance 192.168.202.0/24, then yes
dyn-1 will be 192.168.202.0, but if you use start,end to specify the
range, then the start address becomes dyn-1, so for

--synth-domain=gently.org.uk,192.168.202.50,192.168.202.70,dyn-*

192.168.202.50 is dyn-1

(or maybe dyn-0. Do we want this one-based or zero-based? Having a
choice is NOT an option)

Cheers,

Simon.
Post by Andy Hawkins
It's hardly the end of the world if I have to manually enter each one
though, so I wouldn't push for this change too much if it turned out to be
particularly difficult or generate any strong objections.
Andy
_______________________________________________
Dnsmasq-discuss mailing list
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Andy Hawkins
2018-02-19 09:16:40 UTC
Permalink
Hi,
Post by Simon Kelley
My second example gives exactly that. To clarify, the serial numbers in
the names correspond to the addresses in the range supplied. If you use
a subnet to specify the range, for instance 192.168.202.0/24, then yes
dyn-1 will be 192.168.202.0, but if you use start,end to specify the
range, then the start address becomes dyn-1, so for
--synth-domain=gently.org.uk,192.168.202.50,192.168.202.70,dyn-*
192.168.202.50 is dyn-1
Ah, apologies, I hadn't realised that. In that case then, this sounds
perfect to meet my needs.
Post by Simon Kelley
(or maybe dyn-0. Do we want this one-based or zero-based? Having a
choice is NOT an option)
I think I'd want dyn-1 personally, but don't feel particularly strongly
about it either way to be honest.

Thanks.

Andy
Simon Kelley
2018-03-10 20:30:39 UTC
Permalink
Finally got around to doing this.

http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=6b2b564ac34cb3c862f168e6b1457f9f0b9ca69c


Cheers,

Simon.
Post by Andy Hawkins
Hi,
Post by Simon Kelley
My second example gives exactly that. To clarify, the serial numbers in
the names correspond to the addresses in the range supplied. If you use
a subnet to specify the range, for instance 192.168.202.0/24, then yes
dyn-1 will be 192.168.202.0, but if you use start,end to specify the
range, then the start address becomes dyn-1, so for
--synth-domain=gently.org.uk,192.168.202.50,192.168.202.70,dyn-*
192.168.202.50 is dyn-1
Ah, apologies, I hadn't realised that. In that case then, this sounds
perfect to meet my needs.
Post by Simon Kelley
(or maybe dyn-0. Do we want this one-based or zero-based? Having a
choice is NOT an option)
I think I'd want dyn-1 personally, but don't feel particularly strongly
about it either way to be honest.
Thanks.
Andy
_______________________________________________
Dnsmasq-discuss mailing list
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Dominik DL6ER
2018-02-19 09:41:01 UTC
Permalink
Post by Simon Kelley
To clarify, the serial numbers in
the names correspond to the addresses in the range supplied. If you use
a subnet to specify the range, for instance 192.168.202.0/24, then yes
dyn-1 will be 192.168.202.0, but if you use start,end to specify the
range, then the start address becomes dyn-1
That's exactly why I think zero-indexed would be better, as dyn-50 would
then also correspond to 192.168.202.50. For custom ranges (not starting
from zweo) I have no preference, but the logic should obviously be the
same as for the full /24 network.

Best regards,
Dominik
Geert Stappers
2018-02-19 11:10:16 UTC
Permalink
Post by Dominik DL6ER
Post by Simon Kelley
To clarify, the serial numbers in
the names correspond to the addresses in the range supplied. If you use
a subnet to specify the range, for instance 192.168.202.0/24, then yes
dyn-1 will be 192.168.202.0, but if you use start,end to specify the
range, then the start address becomes dyn-1
That's exactly why I think zero-indexed would be better, as dyn-50 would
then also correspond to 192.168.202.50. For custom ranges (not starting
from zweo) I have no preference, but the logic should obviously be the
same as for the full /24 network.
Here another +1 for starting at 0.

So
| --synth-domain=gently.org.uk,192.168.202.50,192.168.202.70,dyn-*
would in /etc/hosts format
192.168.202.50 dyn-0.gently.ork.uk
192.168.202.51 dyn-1.gently.ork.uk
192.168.202.52 dyn-2.gently.ork.uk

And indeed, on networks where network address ends on zero,
there it will be
192.0.2.0 string0
192.0.2.1 string1
192.0.2.2 string2
192.0.2.3 string3


Another thing, "rollover"
192.0.2.9 string9
192.0.2.10 string10

Should it be "%03d", so
192.0.2.8 string008
192.0.2.9 string009
192.0.2.10 string010
#
192.0.2.99 string099
192.0.2.100 string100
192.0.2.101 string101


Groeten
Geert Stappers
--
Leven en laten leven
Loading...