# IPv6 DHCP



## duk2nuk (Aug 23, 2020)

I am trying to setup my Freebsd router to work with ipv6 and to assign ipv6 address for my LAN hosts based on their mac-address.
Here is my rc.conf (other options are skipped)

```
ipv6_gateway_enable="YES"
ifconfig_re0_ipv6="inet6 2001:db8:acad:a::1 prefixlen 64"
rtadvd_enable="YES"
rtadvd_interface="re0"
dhcpd6_enable="YES"
dhcpd6_conf=/usr/local/etc/dhcpd6.conf
dhcpd6_ifaces="re0"
```
dhcpd6.conf:

```
default-lease-time 2592000;
preferred-lifetime 604800;
option dhcp-renewal-time 3600;
option dhcp-rebinding-time 7200;
allow leasequery;
option dhcp6.domain-search "tomilino.org";
option dhcp6.info-refresh-time 21600;
dhcpv6-lease-file-name "/var/db/dhcpd6/dhcpd6.leases";

subnet6 2001:db8:acad:a::/64 {
    range6 2001:db8:acad:a::20 2001:db8:acad:a::25;
}
host arch {
  hardware ethernet 70:8b:cd:a2:99:62;
  fixed-address6 2001:db8:acad:a::6;
    fixed-prefix6 2001:db8:acad:a::/64;
}
host server-win {
  hardware ethernet 82:e1:9d:18:48:af;
  fixed-address6 2001:db8:acad:a::7;
    fixed-prefix6 2001:db8:acad:a::/64;
}
```
and my rtadvd.conf:

```
re0:\
  :addrs#1:addr="2001:db8:acad:a::":prefixlen#64:tc=ether:
```

Any linux host in my LAN-network gets an ip address from rtadvd and not from dhcp, but Windows 2012 Server gets two ipv6 addresses: from dhcp and from SLAAC. 
What I am doing wrong?


----------



## xtaz (Aug 23, 2020)

You need to set the managed mode flag "m" in the router advertisement from rtadvd. I believe you need raflags="mo". Managed mode is what makes hosts get their address from DHCPv6. You probably also want to set pinfoflags="l" as the default for that includes a which is autonomous mode which is what triggers SLAAC.

The reason you're seeing different behavior with Windows is because Windows ignores RFCs and just does what it likes.


----------



## duk2nuk (Aug 25, 2020)

Thank you! Now my Windows and Mac OSX hosts get ipv6 from DHCP. Linux still has some problems: it gets ipv6 from DHCP, but not fixed address, but a dynamic one.


----------



## xtaz (Aug 25, 2020)

I think using the MAC address for DHCPv6 can be problematic. They recommend using DUID instead. Linux I think has some privacy options which randomizes the MAC address so the DHCP server might not be seeing the real MAC?

I don't use isc-dhcpd, i use its replacement called kea. But I had to use an option called duid rather than hw-address. And I got the DUID out of the syslog during the first time it tried to get a lease.


----------

