Re: DHCPv6 without SLAAC
Roy Marples
Fri Jan 02 09:59:25 2015
Hi Joachim
On Tuesday 30 Dec 2014 16:05:56 Joachim Achtzehnter wrote:
> Further on the desire for an option to configure a specific interface on
> a specific host to assign only a DHCP address, but not assign any
> autonomously chosen SLAAC addresses: One way to provide this option is
> illustrated by the attached patch.
>
> This relies on the caller of dhcpcd to set the kernel parameters
> (accept_ra==1, autoconf==0). This is how ifup from the ifupdown package
> would configure this use case if it supported dhcpcd for IPv6. I've
> tried this and it does what I want, with two small problems, which I
> think are unrelated issues.
>
> The patch is only intended as an illustration, I'm not familiar enough
> with the dhcpcd implementation to know whether this is an appropriate
> way to do it.
We cannot use that kernel tunable because if dhcpcd wants to own the RA
entirely it will disable it anyway, so a future restart of dhcpcd may not work
the same way as the first pass.
Attached is a better patch which adds noipv6ra_autoconf as a tunable in
dhcpcd.conf. Let me know if that works for you.
> Here are the two remaining problems:
>
> 1) For some reason the DHCP address is added with a prefix length of 128
> instead of 64. The router advertises a prefix with length 64.
DHCPv6 IA_NA and IA_TA messages have no notion of prefix length - it's just an
address.
http://www.ietf.org/mail-archive/web/v6ops/current/msg17669.html
> 2) The hook script does not seem to get called after the DHCP address
> was bound (at least not when starting up with an existing lease), it is
> only called for the receipt of the RA.
dhcpcd[6738]: wlp4s0: vltime 5800 seconds, pltime 3625 seconds
dhcpcd[6738]: wlp4s0: renew in 1812 seconds, rebind in 2900 seconds
dhcpcd[6738]: wlp4s0: writing lease `/var/db/dhcpcd-wlp4s0.lease6'
dhcpcd[6738]: wlp4s0: waiting for DHCPv6 DAD to complete
dhcpcd[6738]: wlp4s0: Router Advertisement DAD completed
dhcpcd[6738]: wlp4s0: executing `/libexec/dhcpcd-run-hooks' ROUTERADVERT
dhcpcd[6738]: wlp4s0: DHCPv6 DAD completed
dhcpcd[6738]: wlp4s0: executing `/libexec/dhcpcd-run-hooks' BOUND6
Thanks
Roy
Index: dhcpcd.conf.5.in
==================================================================
--- dhcpcd.conf.5.in
+++ dhcpcd.conf.5.in
@@ -20,11 +20,11 @@
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 13, 2014
+.Dd January 2, 2015
.Dt DHCPCD.CONF 5
.Os
.Sh NAME
.Nm dhcpcd.conf
.Nd dhcpcd configuration file
@@ -342,10 +342,19 @@
encodes the FQDN hostname as specified in
.Li RFC1035 .
.It Ic interface Ar interface
Subsequent options are only parsed for this
.Ar interface .
+.It Ic ipv6ra_autoconf
+Generate SLAAC addresses for each Prefix advertised by a Router Advertisement
+message with the Auto flag set.
+See the
+.Ic slaac
+option for different methodoligies of generating the SLAAC address.
+This set by default.
+.It Ic noipv6ra_autoconf
+Disable the above.
.It Ic ipv6ra_fork
By default, when
.Nm dhcpcd
receives an IPv6 RA,
.Nm dhcpcd
Index: if-options.c
==================================================================
--- if-options.c
+++ if-options.c
@@ -91,10 +91,12 @@
#define O_IPV6 O_BASE + 33
#define O_CONTROLGRP O_BASE + 34
#define O_SLAAC O_BASE + 35
#define O_GATEWAY O_BASE + 36
#define O_PFXDLGMIX O_BASE + 37
+#define O_IPV6RA_AUTOCONF O_BASE + 38
+#define O_NOIPV6RA_AUTOCONF O_BASE + 39
const struct option cf_options[] = {
{"background", no_argument, NULL, 'b'},
{"script", required_argument, NULL, 'c'},
{"debug", no_argument, NULL, 'd'},
@@ -178,10 +180,12 @@
{"nodhcp6", no_argument, NULL, O_NODHCP6},
{"controlgroup", required_argument, NULL, O_CONTROLGRP},
{"slaac", required_argument, NULL, O_SLAAC},
{"gateway", no_argument, NULL, O_GATEWAY},
{"ia_pd_mix", no_argument, NULL, O_PFXDLGMIX},
+ {"ipv6ra_autoconf", no_argument, NULL, O_IPV6RA_AUTOCONF},
+ {"noipv6ra_autoconf", no_argument, NULL, O_NOIPV6RA_AUTOCONF},
{NULL, 0, NULL, '\0'}
};
static int
atoint(const char *s)
@@ -1214,10 +1218,16 @@
ifo->options |= DHCPCD_IPV6RA_OWN;
break;
case O_IPV6RA_OWN_D:
ifo->options |= DHCPCD_IPV6RA_OWN_DEFAULT;
break;
+ case O_IPV6RA_AUTOCONF:
+ ifo->options |= DHCPCD_IPV6RA_AUTOCONF;
+ break;
+ case O_NOIPV6RA_AUTOCONF:
+ ifo->options &= ~DHCPCD_IPV6RA_AUTOCONF;
+ break;
case O_NOALIAS:
ifo->options |= DHCPCD_NOALIAS;
break;
#ifdef INET6
case O_IA_NA:
@@ -2026,11 +2036,12 @@
#ifdef INET
ifo->options |= DHCPCD_IPV4 | DHCPCD_DHCP | DHCPCD_IPV4LL;
ifo->options |= DHCPCD_GATEWAY | DHCPCD_ARP;
#endif
#ifdef INET6
- ifo->options |= DHCPCD_IPV6 | DHCPCD_IPV6RS | DHCPCD_IPV6RA_REQRDNSS;
+ ifo->options |= DHCPCD_IPV6 | DHCPCD_IPV6RS | DHCPCD_IPV6RA_AUTOCONF;
+ ifo->options |= DHCPCD_IPV6RA_REQRDNSS;
ifo->options |= DHCPCD_DHCP6;
#endif
ifo->timeout = DEFAULT_TIMEOUT;
ifo->reboot = DEFAULT_REBOOT;
ifo->metric = -1;
Index: if-options.h
==================================================================
--- if-options.h
+++ if-options.h
@@ -104,10 +104,11 @@
#define DHCPCD_DHCP (1ULL << 49)
#define DHCPCD_DHCP6 (1ULL << 50)
#define DHCPCD_NOPFXDLG (1ULL << 51)
#define DHCPCD_PFXDLGONLY (1ULL << 52)
#define DHCPCD_PFXDLGMIX (1ULL << 53)
+#define DHCPCD_IPV6RA_AUTOCONF (1ULL << 54)
extern const struct option cf_options[];
struct if_sla {
char ifname[IF_NAMESIZE];
Index: ipv6nd.c
==================================================================
--- ipv6nd.c
+++ ipv6nd.c
@@ -862,11 +862,14 @@
ap->iface = rap->iface;
ap->flags = IPV6_AF_NEW;
ap->prefix_len = pi->nd_opt_pi_prefix_len;
ap->prefix = pi->nd_opt_pi_prefix;
if (pi->nd_opt_pi_flags_reserved &
- ND_OPT_PI_FLAG_AUTO)
+ ND_OPT_PI_FLAG_AUTO
+ &&
+ ifp->options->options &
+ DHCPCD_IPV6RA_AUTOCONF)
{
ap->flags |= IPV6_AF_AUTOCONF;
ap->dadcounter =
ipv6_makeaddr(&ap->addr, ifp,
&ap->prefix,
Archive administrator: postmaster@marples.name