Pi-Star 4.1.0 RC5 IPv6 DUID Bug

All IP networking related issues
Post Reply
Posts: 85
Joined: Mon Aug 20, 2018 5:24 pm

Pi-Star 4.1.0 RC5 IPv6 DUID Bug

Post by K2IE » Thu Sep 12, 2019 8:48 pm

I've been trying to track down why Pi-Star is not getting the statically assigned IPv6 address from the DHCP server on each boot. Something is changing the DUID between boots. I've verified on a non Pi-Star installation that this is not a generic Buster issue, rather it is specific to Pi-Star.

It is messy as Pi-Star gets a different IPv6 address on each boot and is ignoring DHCPv6.

Original DUID:

After boot DUID:

Posts: 85
Joined: Mon Aug 20, 2018 5:24 pm

Re: Pi-Star 4.1.0 RC5 IPv6 DUID Bug

Post by K2IE » Thu Sep 12, 2019 9:03 pm

OK, the problem seems to be that /var/lib/dhcpcd5 is not a permanent filesystem. This is very bad, as DUID should be unique and never change between reboots. If /var/lib/dhcpcd5 MUST be a tmpfs, the duid needs to be stored somewhere on the sdcard and copied over at boot time.

Posts: 823
Joined: Wed Apr 17, 2019 11:11 pm

Re: Pi-Star 4.1.0 RC5 IPv6 DUID Bug

Post by KE7FNS » Fri Sep 13, 2019 3:58 am

Well thats interesting.

Good find.
If someones previous actions are any indication of their future actions, then I predict the deletion and removal of access will happen at any moment. 7-11-2020.

"07/13/20 This Website Has Been Taken Down" ... again :lol:

Posts: 48
Joined: Fri Sep 21, 2018 2:47 am

Re: Pi-Star 4.1.0 RC5 IPv6 DUID Bug

Post by kc7ngc » Wed Nov 06, 2019 2:10 am

Not meaning to dig up an old thread, but since this is something I had solved on my own before I saw this thread figured would share. This could use some cleaning up. Apologize if I missed something in this post. As going back to document something I did a bit ago is always harder than had I documented it in the first place.


On boot the:

duidsave.service service is set to run after /var/lib/dhcpcd5 is mounted in tmpfs but before dhcpcd5 is ran.
Is runs /usr/local/sbin/duid-save.sh restore
If /usr/local/etc/dhcpcd5/duid file exists then it creates a ln from /var/lib/dhcpcd5/duid to /usr/local/etc/dhcpcd5/duid

duid-save runs by cron to see if duid needs to be save. I tried putting a service to run after dhcpcd5 came up and created a new duid on first boot but has race conditions so cron seemed a good compromise.
"duid-save.sh save" checks if different between /var/lib/dhcp5/duid and /usr/local/etc/dhcpcd5/duid
if their is a different then it makes sure that the /usr/local/etc/dhcpcd5 directory is created and dumps the duid into that directory.

Really this needs to be a oneshot deal, as once duid is saved to nonvolatile storage it doesn't need to run again. But right now it runs and checks if duid on disk is different than in tmp and will archive it away. Might be a better way to do a oneshot trigger to save duid after dhcpcd5 service creates it but I didn't put much effort into it as this worked for my purposes.


Code: Select all

/usr/local/sbin/duid-save.sh save


Code: Select all

function save {
  # check if persistent duid is different that tmpfs one
  if ! cmp -s /usr/local/etc/dhcpcd5/duid /var/lib/dhcpcd5/duid  ; then
        # check if we need to remount rw
        if fgrep -q "/dev/root / ext4 ro" /proc/mounts ; then
                # mounted ro so mount rw
                        mount -o remount,rw /
        if [ ! -d "/usr/local/etc/dhcpcd5" ]; then
                # if directory doesn't exist make it
                mkdir /usr/local/etc/dhcpcd5
        cp /var/lib/dhcpcd5/duid /usr/local/etc/dhcpcd5/
        if [[ $remountit == "1" ]]; then
                # if we mounted as RW then put back to RO
               mount -o remount,ro /

if [ "$1" = "restore" ]; then
        if [ -f "/usr/local/etc/dhcpcd5/duid" ]; then
               rm /var/lib/dhcpcd5/duid
               ln -s  /usr/local/etc/dhcpcd5/duid /var/lib/dhcpcd5/duid

if [ "$1" = "save" ]; then

if [ "$1" = "new" ]; then
        # remove duid from tmpfs
        rm /var/lib/dhcpcd5/duid
        # restart dhcpcd5
        service dhcpcd5 restart
        # save new duid


Code: Select all

Description=Populate dhcpcd4 DUID to tmpfs

ExecStart=/bin/bash -c "/usr/local/sbin/duid-save.sh restore"


Once those files are in place then:

Code: Select all

sudo chmod +x /etc/cron.hourly/duid-save.sh
sudo chmod +x /usr/local/sbin/duid-save.sh
sudo ln -s /etc/systemd/system/duidsave.service /etc/systemd/system/multi-user.target.wants/duidsave.service

Post Reply