diff mbox

[OpenWrt-Devel,RESEND] dnsmasq: add config option for ra_names

Message ID 1451408331-31283-1-git-send-email-asmadeus@codewreck.org
State Changes Requested
Headers show

Commit Message

Dominique Martinet Dec. 29, 2015, 4:58 p.m. UTC
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---

I posted this quite another while ago:
Dominique Martinet wrote on Sun, Jul 14, 2013:
> I posted this quite a while ago:
> Dominique Martinet wrote on Fri, Jul 06, 2012:
>> ra_names is a feature introduced in dnsmasq 2.61, which is why I changed
>> the rules to build something newer (and figured I might as well take it
>> to 62)
>> Basically, it:
>>  - does router-advertisment (not dhcpv6)
>>  - when it gets a request for RA, it looks up if there is an active ipv4
>>  lease for the same host via its MAC address, and if there is it adds
>>  the to-be ipv6 to the local dns (assuming the host will take the dns)
>>  - when it gets a dhcpv4 release it takes off the ipv6 dns record as
>>  well
>> 
>> (since RA is stateless and doesn't give the host name, I couldn't figure
>> any better way without dhcpv6; I was about to hack something (with a
>> very large axe and radvd) when I found out they've done it already :D)
>> 
>> There are also modes for router-advertisment only which I haven't looked
>> at, and a dhcpv6 client implementation that I didn't try yet either.
>> 
>> 
>> The option I added is in the dhcp field, a "ra_name" option with the
>> prefix to announce in RAs, i.e.
>> 
>> config dhcp 'lan'
>> 	option interface 'lan'
>> 	option ra_names '2001:dead:beef::'
>
>
> Since I re-installed my router I looked to see if there was another way
> to give dnsmasq a custom option, but couldn't find any - maybe I'm just
> blind though.
>
> That being said, I think this is a nice feature for anyone with a dual
> stack ipv4/ipv6 at home, it "just works", and if there is no other clean
> way to add this in the config I wouldn't mind getting this added.
> If you have any suggestion/qualms about it, please tell me and I'm
> willing to try to get these fixed before sending a new patch.
> (unless of course it's a "we're not interested" - but if I just need to
> add a checkbox to luci I'll consider it.)
>
> The original patch inclued a dnsmasq version bump which isn't needed
> anymore, so here's the short bit that would interest me:
> (just checked it still applies to trunk one year later, I just had to
> change the file path. This mail should apply with git am/git apply.)

The patch didn't get any reply so I guess it's more of a "we're not interested"
kind of answer, but I still like this option so trying my chance again...
Maybe now more people (hopefully) have ipv6 this will get a new look.

 package/network/services/dnsmasq/files/dnsmasq.init |    6 ++++++
 1 file changed, 6 insertions(+)

Comments

Felix Fietkau Jan. 3, 2016, 8:28 p.m. UTC | #1
On 2015-12-29 17:58, Dominique Martinet wrote:
> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
> ---
> 
> I posted this quite another while ago:
> Dominique Martinet wrote on Sun, Jul 14, 2013:
>> I posted this quite a while ago:
>> Dominique Martinet wrote on Fri, Jul 06, 2012:
>>> ra_names is a feature introduced in dnsmasq 2.61, which is why I changed
>>> the rules to build something newer (and figured I might as well take it
>>> to 62)
>>> Basically, it:
>>>  - does router-advertisment (not dhcpv6)
>>>  - when it gets a request for RA, it looks up if there is an active ipv4
>>>  lease for the same host via its MAC address, and if there is it adds
>>>  the to-be ipv6 to the local dns (assuming the host will take the dns)
>>>  - when it gets a dhcpv4 release it takes off the ipv6 dns record as
>>>  well
>>> 
>>> (since RA is stateless and doesn't give the host name, I couldn't figure
>>> any better way without dhcpv6; I was about to hack something (with a
>>> very large axe and radvd) when I found out they've done it already :D)
>>> 
>>> There are also modes for router-advertisment only which I haven't looked
>>> at, and a dhcpv6 client implementation that I didn't try yet either.
>>> 
>>> 
>>> The option I added is in the dhcp field, a "ra_name" option with the
>>> prefix to announce in RAs, i.e.
>>> 
>>> config dhcp 'lan'
>>> 	option interface 'lan'
>>> 	option ra_names '2001:dead:beef::'
>>
>>
>> Since I re-installed my router I looked to see if there was another way
>> to give dnsmasq a custom option, but couldn't find any - maybe I'm just
>> blind though.
>>
>> That being said, I think this is a nice feature for anyone with a dual
>> stack ipv4/ipv6 at home, it "just works", and if there is no other clean
>> way to add this in the config I wouldn't mind getting this added.
>> If you have any suggestion/qualms about it, please tell me and I'm
>> willing to try to get these fixed before sending a new patch.
>> (unless of course it's a "we're not interested" - but if I just need to
>> add a checkbox to luci I'll consider it.)
>>
>> The original patch inclued a dnsmasq version bump which isn't needed
>> anymore, so here's the short bit that would interest me:
>> (just checked it still applies to trunk one year later, I just had to
>> change the file path. This mail should apply with git am/git apply.)
> 
> The patch didn't get any reply so I guess it's more of a "we're not interested"
> kind of answer, but I still like this option so trying my chance again...
> Maybe now more people (hopefully) have ipv6 this will get a new look.
> 
>  package/network/services/dnsmasq/files/dnsmasq.init |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
> index 630c07d..a2f274e 100644
> --- a/package/network/services/dnsmasq/files/dnsmasq.init
> +++ b/package/network/services/dnsmasq/files/dnsmasq.init
> @@ -375,6 +375,12 @@ dhcp_add() {
>  	xappend "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}"
>  
>  	dhcp_option_add "$cfg" "$networkid"
> +
> +	config_get ra_names "$cfg" ra_names
> +
> +	[ -n "$ra_names" ] && {
> +		xappend "--dhcp-range=$networkid,$ra_names,ra-names,$leasetime"
> +	}
It seems to me that configuring this manually limits its use. Wouldn't
it be better to integrate it with OpenWrt's prefix delegation support?
this would make it work with dynamically assigned prefixes.

When the init script runs, it could query netifd for assigned prefixes
belonging to that particular interface, and use those for ra_names.

- Felix
Dominique Martinet Jan. 4, 2016, 10:10 a.m. UTC | #2
Felix Fietkau wrote on Sun, Jan 03, 2016:
> It seems to me that configuring this manually limits its use. Wouldn't
> it be better to integrate it with OpenWrt's prefix delegation support?
> this would make it work with dynamically assigned prefixes.
>
> When the init script runs, it could query netifd for assigned prefixes
> belonging to that particular interface, and use those for ra_names.

I actually hadn't upgraded yet when I sent this, it looks like there has
been alot of work towards integrating IPv6 more generally since I had
written this patch. I agree we can do better nowadays, I'll take a look
at it... Except that I noticed dnsmasq is compiled with no-dhcpv6?

What is the reasoning for it?

This breaks both the patch I've just resubmit (sorry for not checking
beforehand) and these two lines that my config used to have (which are
also used for RDNSS and DNSSL router advertisements, but require dhcpv6
to be parsed I guess):

dhcp-option=lan,option6:dns-server,[::]
dhcp-option=lan,option6:domain-search,lan

Without these, an ipv6-only device can not pickup a dns server and
search domain.


I also have backported the qos ipv6 patch Ilkka Ollakka made a couple of
years ago that hadn't been picked, I'll resend this as soon as I've
confirmed I'm happy with it myself (there's been a change with locking
in iptables and -w doesn't seem to cut it, I'll need to take some time
to debug a bit)

Thanks,
Dominique Martinet Jan. 4, 2016, 10:21 a.m. UTC | #3
Dominique Martinet wrote on Mon, Jan 04, 2016:
> I actually hadn't upgraded yet when I sent this, it looks like there has
> been alot of work towards integrating IPv6 more generally since I had
> written this patch. I agree we can do better nowadays, I'll take a look
> at it... Except that I noticed dnsmasq is compiled with no-dhcpv6?
> 
> What is the reasoning for it?

Answering myself as I noticed the dnsmasq variants packaged, not sure
how to make a change to the init script if and only if said variant is
in though. Happy to take suggestions.
Felix Fietkau Jan. 4, 2016, 10:25 a.m. UTC | #4
On 2016-01-04 11:21, Dominique Martinet wrote:
> Dominique Martinet wrote on Mon, Jan 04, 2016:
>> I actually hadn't upgraded yet when I sent this, it looks like there has
>> been alot of work towards integrating IPv6 more generally since I had
>> written this patch. I agree we can do better nowadays, I'll take a look
>> at it... Except that I noticed dnsmasq is compiled with no-dhcpv6?
>> 
>> What is the reasoning for it?
> 
> Answering myself as I noticed the dnsmasq variants packaged, not sure
> how to make a change to the init script if and only if said variant is
> in though. Happy to take suggestions.
Actually, the main reason is the fact that odhcpd handles dhcpv6 and
router advertisement. Do you really need dnsmasq to do dhcpv6 for this
to work?

- Felix
Dominique Martinet Jan. 4, 2016, 11:02 a.m. UTC | #5
Felix Fietkau wrote on Mon, Jan 04, 2016:
> On 2016-01-04 11:21, Dominique Martinet wrote:
> > Dominique Martinet wrote on Mon, Jan 04, 2016:
> >> I actually hadn't upgraded yet when I sent this, it looks like there has
> >> been alot of work towards integrating IPv6 more generally since I had
> >> written this patch. I agree we can do better nowadays, I'll take a look
> >> at it... Except that I noticed dnsmasq is compiled with no-dhcpv6?
> >> 
> >> What is the reasoning for it?
> > 
> > Answering myself as I noticed the dnsmasq variants packaged, not sure
> > how to make a change to the init script if and only if said variant is
> > in though. Happy to take suggestions.
>
> Actually, the main reason is the fact that odhcpd handles dhcpv6 and
> router advertisement. Do you really need dnsmasq to do dhcpv6 for this
> to work?

Oh, hadn't noticed odhcpd running.

The full option for ra-names is as follow:
dhcp-range=lan,2001:910:1115::,ra-names,12h

(where the prefix is mine and 12h is the dhcpv4 lease time)

So yes, it will need dnsmasq to be compiled in with dhcpv6 and I cannot
think of any way to make it not try to handle it at the same time.


Not sure how to make it work at all with this setup though, from a
theorical point of view dnsmasq gets the mac/hostname relation from the
dhcp (v4) lease but only adds the ipv6 to the DNS when a RA is processed
(in dnsmasq logs SLAAC-CONFIRM); I assume if odhcpd handles the ipv6
then dnsmasq will not get/parse these anyway and will not be able to add
the dns automatically...

I'm seeing odhcpd has a "leasetrigger" option and the default script
makes dnsmasq reload the lease file, but ipv6 does not have a 'lease'
concept for RA so that file is empty...

I'm afraid this is going to end in me being selfish and using a 'fuller'
dnsmasq unfortunately, unless you have any idea there :/
Having the dns autoconfiguration for dynamic VMs/hosts/guests through
their dhcp hostname is kind of important to me.
Kevin Darbyshire-Bryant Jan. 4, 2016, 12:53 p.m. UTC | #6
On 04/01/16 11:02, Dominique Martinet wrote:
> Felix Fietkau wrote on Mon, Jan 04, 2016:
>> On 2016-01-04 11:21, Dominique Martinet wrote:
>> I'm afraid this is going to end in me being selfish and using a
>> 'fuller' dnsmasq unfortunately, unless you have any idea there :/
>> Having the dns autoconfiguration for dynamic VMs/hosts/guests through
>> their dhcp hostname is kind of important to me. 

Hi Dominique,

I run my openwrt router using dnsmasq for ipv6 (the full dnsmasq
package) purposes, I also disable 'odhcpd' from the build.  Bear in mind
that you can update '/etc/dnsmasq.conf' for your own purposes as I do,
maybe this helps you a little?  e.g

quiet-dhcp                                           
quiet-dhcp6
quiet-ra                                                             
                                                               
dhcp-range=lan,::2, ::FFFF:FFFF, constructor:br-lan,64, 12h
                  
enable-ra
ra-param=br-lan,high,0.


Also, you may be interested in
https://patchwork.ozlabs.org/patch/513484/ which allows easier fixed
host MAC to IPv4 & IPv6 mapping.

Kind regards,

Kevin
diff mbox

Patch

diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index 630c07d..a2f274e 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -375,6 +375,12 @@  dhcp_add() {
 	xappend "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}"
 
 	dhcp_option_add "$cfg" "$networkid"
+
+	config_get ra_names "$cfg" ra_names
+
+	[ -n "$ra_names" ] && {
+		xappend "--dhcp-range=$networkid,$ra_names,ra-names,$leasetime"
+	}
 }
 
 dhcp_option_add() {