christoph ender's

blog

friday the 28th of april, 2023

fixed ipv6 assignment

While SLAAC is very conveninent to get multiple hosts configured with minimum effort for ipv6, it's often nice to have a set of shorter addresses for some hosts – it's much easier to remember fd00:0:0:10::1 than fd00:0:0:10:3047:8f88:6801:87b0.

This can be achieved by setting up your own router advertisement and dhcpv6 server. Using radvd, we're setting up our own example unique local address range fd00:0:0:10::/64 in /etc/radvd.conf:

interface eth0 {
  AdvSendAdvert on;
  AdvManagedFlag on;

  prefix fd00:0:0:10::/64 {
    AdvOnLink on;
    AdvAutonomous off;
  };
};

Setting AdvManagedFlag on will make hosts setting up ipv6 on eth0 query the local dhcpv6 server for an ip address in our example prefix range. The AdvAutonomous off statement will ensure that ip addresses for the given prefix are only assigned by the dhcpv6 server, so that interfaces don't get multiple addresses in the fd00:0:0:10::/64 range due to SLAAC.

ISC's dhcpd server can be used to handle the dhcp requests. In /etc/dhcp/dhcpd6.conf, we'll set up our host “my-machine” so that it is always assigned ip fd00:0:0:10::1. The host is identified by it's DUID – the DHCP unique identifier – following dhcp6.client-id. The DUID can be obtained from your OS, although I found it more convenient to just look at dhcpd's logs when ip address are advertised. All other hosts are assigned addresses from the pool defined by the range6 statement.

subnet6 fd00:0:0:10::/64 {
  range6 fd00:0:0:10::1000 fd00:0:0:10::1fff;

  host my-machine {
    host-identifier option dhcp6.client-id 00:01:00:05:79:cb:06:ac:b0:88:17:7b:dd:bf;
    fixed-address6 fd00:0:0:10::1/64;
  }
}

In case unknown clients shouldn't get any address at all, the range6 statement can be replaced by deny unknown-clients. Also, assigning the system's own fixed ip via dhcpcd might be “too slow” after booting and dhcpd might come to the conclusion that the address space it's providing dhcp for doesn't exist and complain “No subnet6 declaration for eth0 (no IPv6 addresses)”. In this case, set denyinterfaces eth0 in /etc/dhcpcd.conf and configure the interface using /etc/network/interfaces or related.