Skip to content

Support for IPv6 DHCP #2103

Closed
Closed

Description

@JedMeister

Ideally it would be great to have full support for IPv6 IP assignment by DHCP. @marcos-mendez had a go at it in turnkeylinux/common#339 - using dhcpcd. But as I noted in turnkeylinux/common#339 (comment) unfortunately:

dhcpcd is not compatible with ifupdown & use of the /etc/network/interfaces file.

It also notes that static IPs need to be configured in /etc/dhcpcd.conf which changes our network config completely. And may not be compatible with setting static IPs with Proxmox LXC containers (when you set a static IP in PVE the PVE hosts modifies the LXC guest's /etc/network/interfaces).

My research suggests that our current stack should "just work" with SLAAC (Stateless Address Autoconfiguration) if we add this line to the interfaces file:

iface eth0 inet6 auto

Also apparently ifupdown should already support IPv6 DHCP, but it still needs a DHCP client (and udhcpd only provides IPv4 DHCP). FWIW the interfaces file line is:

iface eth0 inet6 dhcp

Possible alternate options:

  • dhcpcd-base (a dependency of dhcpcd) is apparently compatible with ifupdown//etc/network/interfaces file.
  • wide-dhcpv6-client - a DHCPv6 client that also apparently works alongside ifupdown for IPv6.

I'm not completely against moving to another DHCP client that uses a completely different config, but moving away from using ifupdown//etc/network/interfaces file will require a bit of work elsewhere to make it work with our existing tools - work that I'm not keep to embark on at this late stage of the v19.x dev cycle (& v19.0 is already WAY overdue...). And my above note re Proxmox also needs investigation and consideration.

Options that don't use ifupdown//etc/network/interfaces file:

  • dhcpcd - as proposed by @marcos-mendez - static interface conf goes in /etc/dhcpcd.conf`.
  • [systemd-networkd] - my feelings re systemd are mixed but AFAIK use of networkd would not require any additional packages. It uses .network files, which natively handle both IPv4 and IPv6.

I'd be particularly interested in your thoughts @marcos-mendez.

I'm also not sure what we should do with the changes we made to support IPv6 in Confconsole?! Perhaps we should roll that back for now? I imagine that the changes to IPv6 support in Webmin should be fine as-is?


Replaces: #1459

Activity

  1. added this to the 19.1 milestone on Apr 13, 2026
  2. added
    common
    on Apr 13, 2026
  3. marcos-mendez commented on Apr 13, 2026

    @marcos-mendez
    Member

    Thanks for the detailed writeup @JedMeister . Some context and findings from our side:
    The dhcpcd work wasn't speculative
    We needed IPv6 working end-to-end to test ejabberd (s2s federation) and FreePBX on IPv6-only containers in our infra. Without it, confconsole reported "not configured" on hosts with valid IPv6 addresses. That's what drove both the dhcpcd change and the confconsole patches.
    We already validated dhcpcd-base + ifupdown
    The good news: our approach is already compatible with ifupdown. Here's what we found:

    ifupdown 0.8.44 (Trixie) declares Recommends: dhcpcd-base | dhcp-client — it natively supports it
    We installed dhcpcd, masked the daemon (/dev/null), and ifup invokes it on-demand
    /etc/network/interfaces remains the single source of truth
    Proxmox LXC static IP injection works unchanged
    We later found that inet6 dhcp stanzas are redundant — dhcpcd handles dual-stack (DHCPv4 + SLAAC + DHCPv6) in a single call

    So the interfaces file stays simply iface eth0 inet dhcp — dhcpcd does the rest.
    If you'd prefer installing only dhcpcd-base instead of the full package (skipping the daemon masking), happy to test and submit a revised PR.
    Confconsole
    I'd suggest keeping the IPv6 display changes — showing the IPv6 address on the services screen is useful no matter how the address was obtained. The _validip() fix (checking IPv6 when no IPv4 exists) prevents false "not configured" on IPv6-only hosts. We could split the PR if you want: detection/display separate from the dhcpcd retry loop.
    Proxmox
    Fully agree this is essential — most TKL users today are probably on PVE. Everything we tested preserves /etc/network/interfaces as the config path, so PVE static IP injection works as expected.
    Why IPv6 matters for TKL
    ISPs are increasingly deploying CGNAT to cope with IPv4 exhaustion — users behind it can't host services or accept inbound connections. IPv6 restores end-to-end connectivity, which is exactly what TKL is about: empowering people to run their own infrastructure. At our cooperative (pop.coop) we run IPv6-first in production and we're happy to keep contributing on this front.

  4. JedMeister commented on Apr 14, 2026

    @JedMeister
    MemberAuthor

    Thanks @marcos-mendez. I appreciate the context and I'm keen to add "first class" IPv6 support and it sounds like not having it is essentially a "deal breaker" for you. I assume that there will be many others in the same boat...

    So I have done a fair bit of testing and I'm pretty sure I've discovered the issue. FWIW I have replaced dhcpcd with dhcpd-base as well. So the first issue is that the networking.service wasn't enabled by default. TBH I'm not sure why that is but it's an easy fix...

    The next issue I hit was a side effect of DHCP "hanging" at boot - not really hanging, but taking a long time: ~4 secs. I tried configuring dhcpcd to not block the boot (run in the background) which shaved that ~4 secs off the boot time, but caused a new issue: confconsole starts before the network config is complete so it thinks that it doesn't have a network connection (because it doesn't at that point).

    After about 4 hours of diagnosis and testing I've worked out what the actual problem is. dhcpcd is taking ages doing an ARP probe to double check that the IP it has leased/cached isn't already taken. Removing the cached lease resolved that, but that's not a "proper" fix because it essentially defeats the whole point of DHCP leases in the first place... After burning so much time I didn't go too far down the rabbit hole trying to work out why the ARP probe takes so long, but it does seem to be some sort of bug in my local router's DHCP server.

    A bit more reading lead me to understand why it didn't cause an issue before; udhcpd doesn't do the ARP probe by default! That makes it quicker but technically non-compliant with RFC 5227. dhcpcd is RFC-compliant so it's actually doing the "right thing" and exposing an issue with my router that was always there - just wasn't visible.

    My guess is that on your setup @marcos-mendez - your DHCP server responds to the ARP much quicker hence why you didn't see the issue on your end? My router is a higher end "consumer grade" one with pretty good hardware specs and AFAIK it uses dnsmasq as it's DHCP server. So I'm a bit surprised about the issue. Without knowing more about how widespread this issue is I'm not 100% sure how common it will or how much friction it might cause for our users?

    The TL;DR is that my inclination is to disable the ARP probe in dhcpcd config. That will keep the same behavior as we had (with udhcpd) for the last ~14 years. And it won't add to our (i.e. @OnGle and my) dev friction. Fingers crossed that will work for you @marcos-mendez!?

  5. marcos-mendez commented on Apr 14, 2026

    @marcos-mendez
    Member

    Hey Jed, before you continue your investigation I suggest you try Hurricane Electric's Tunnel Broker. It gives you a proper IPv6 /64 over a 6in4 tunnel — dead simple to set up and tear down.

    Here's a small script I use on my workstation (Manjaro, over a VPN interface). You can adapt it to your setup easily:

    #!/bin/bash
    # Enable/Disable Hurricane Electric IPv6 tunnel (over VPN tun0)
    # Author: PopSolutions Cooperativa
    
    # Configuration
    TUNNEL_ID=990122
    UPDATE_URL="https://user:pass@ipv4.tunnelbroker.net/nic/update?hostname=$TUNNEL_ID"
    SERVER_IPV4="216.66.64.154"
    CLIENT_IPV6="2001:470:1f2a:d8::2/64"
    TUN_IF="he-ipv6"
    VPN_IF="tun0"
    GATEWAY_IPV6="2001:470:1f2a:d8::1"
    
    function tunnel_up() {
      echo "[INFO] Discovering current IPv4 on $VPN_IF..."
      CURRENT_IP=$(ip -4 addr show dev $VPN_IF | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n1)
    
      if [[ -z "$CURRENT_IP" ]]; then
        echo "[ERROR] Could not obtain IPv4 from interface $VPN_IF!"
        exit 1
      fi
      echo "[INFO] Current IPv4 ($VPN_IF): $CURRENT_IP"
    
      echo "[INFO] Updating endpoint on Hurricane Electric..."
      RESPONSE=$(curl -s "$UPDATE_URL&myip=$CURRENT_IP")
    
      if [[ "$RESPONSE" == *"good"* ]] || [[ "$RESPONSE" == *"nochg"* ]]; then
        echo "[OK] Endpoint updated successfully: $RESPONSE"
      else
        echo "[ERROR] Failed to update endpoint: $RESPONSE"
        exit 1
      fi
    
      echo "[INFO] Configuring tunnel $TUN_IF..."
      sudo ip tunnel del $TUN_IF 2>/dev/null
      sudo ip tunnel add $TUN_IF mode sit remote $SERVER_IPV4 local $CURRENT_IP dev $VPN_IF ttl 255
      sudo ip link set $TUN_IF up
      sudo ip addr add $CLIENT_IPV6 dev $TUN_IF
      sudo ip -6 route del default 2>/dev/null
      sudo ip -6 route add ::/0 via $GATEWAY_IPV6 dev $TUN_IF
      sudo ip link set $TUN_IF mtu 1480
    
      echo "[OK] Tunnel $TUN_IF configured over $VPN_IF ($CURRENT_IP)."
      echo "Test with: ping -6 google.com"
    }
    
    function tunnel_down() {
      echo "[INFO] Removing tunnel $TUN_IF..."
      sudo ip -6 route del default 2>/dev/null
      sudo ip tunnel del $TUN_IF 2>/dev/null
      echo "[OK] Tunnel $TUN_IF removed."
    }
    
    case "$1" in
      up)
        tunnel_up
        ;;
      down)
        tunnel_down
        ;;
      *)
        echo "Usage: $0 {up|down}"
        exit 1
        ;;
    esac

    This is essentially how SLAAC works in most real-world deployments. If you have a static public IPv4, you can also test this in an environment with standard RA (Router Advertisement) or even BGP — that would let you rule out your router's behavior as the source of the issue once and for all.

    Even enterprise-grade networking gear has its quirks and bugs. A clean HE tunnel gives you a known-good IPv6 path to test against, independent of whatever your local router is doing.

    Note: Replace these configuration values with the ones Hurricane Electric gives you when you create your own tunnel:

    TUNNEL_ID=990122              # Your tunnel ID from the HE panel
    UPDATE_URL="https://user:pass@ipv4.tunnelbroker.net/nic/update?hostname=$TUNNEL_ID"
                                   # Use your HE username and Update Key (not your account password)
    SERVER_IPV4="216.66.64.154"    # "Server IPv4 Address" from your tunnel details
    CLIENT_IPV6="2001:470:1f2a:d8::2/64"  # "Client IPv6 Address" from your tunnel details
    GATEWAY_IPV6="2001:470:1f2a:d8::1"    # "Server IPv6 Address" from your tunnel details

    You can find all of these on the Tunnel Details page after creating your tunnel at https://tunnelbroker.net/. The VPN_IF should be changed to whatever interface has your public IPv4 (e.g. eth0, enp0s3, etc.) — I use tun0 because I run it over a VPN.

  6. marcos-mendez commented on Apr 14, 2026

    @marcos-mendez
    Member

    With this script probably is gonna take you 10 minutes more

  7. JedMeister commented on Apr 16, 2026

    @JedMeister
    MemberAuthor

    Hey @marcos-mendez thanks mate. I'm going to have to circle back to this when I've got a bit more headspace.

    As for this issue itself - IMO it's closed by the implementation in turnkeylinux/common#345. 🎉

    @marcos-mendez - If you still think that there's other IPv6 related stuff to do please open a fresh issue (or 2). 😁

  8. JedMeister commented on Apr 24, 2026

    @JedMeister
    MemberAuthor

    Unfortunately, while testing I have hit more issues re this "first class" IPv6 implementation.

    As discussed, dhcpcd-base does not "clash" with ipupdown and /etc/network/interfaces - at least not technically. Without the "full" dhcpcd package (and the daemon/service) dhcpcd is (somewhat) controlled by ifup/ipdown in the sense that it will stop/start dhcpcd - release/renew interface DHCP lease/s.

    However during further testing I discovered that dhcpcd completely ignores the config in /etc/network/interfaces so does not respect 'static' IP config and continues to get a DHCP lease. That does not actually break the static IP config and it will still work. However it means that you end up with an interface that has multiple IPs. While technically that is still "valid" config, it would certainly be unexpected behavior for most - if not all - users. An additional unexpected/unknown IP address on a network when a TKL server is explicitly configured to use a static IP may lead to concern and/or time wasted trying to work out what is going on. And possibly increase security risks.

    I went down a rabbit hole developing code to resolve that issue and get the same behavior we had previously with udhcpd - i.e. a DHCP or a static IP. I ended up with a partially complete, complex and fragile solution that I wasn't really happy with.

    I seriously considered winding back the IPv6 implementation (again) so I can get back to the last few bits blocking v19.0rc1 release. Then hopefully circle back to IPv6 stuff with hope of including in the stable release. However, I decided to spend a little more time on it.

    In an effort to avoid falling into the "sunk cost" fallacy I completely stepped back from the approach I had been taking. After spending a couple of hours thinking, researching and re-evaluating the whole situation I thought I'd come up with a quite elegant and robust solution using ifupdown hook scripts (a pre-up script and a post-down script). But it's not working how it should - according to the docs there should be some environment vars but they aren't being set... :( And I'm still not sure why?!

    I haven't given up yet, but I've now burned another week trying to get it working as it should so if I can't get it working properly soon I'm going to have to consider winding back the IPv6 changes until we can work it out... I'll have a look with some fresh eyes on Monday and see how I go...

  9. marcos-mendez commented on Apr 24, 2026

    @marcos-mendez
    Member

    Sorry for the delay mate we had a Holiday this week, let me take a look into this and i'll come back to you.

  10. marcos-mendez commented on Apr 24, 2026

    @marcos-mendez
    Member

    Hey @JedMeister — took a closer look at the repo before I reply properly. A couple of things that might save you time:

    1. ifupdown-ng, not classic ifupdown. PR (Jessie) TKLDev SSL crash on make #344 landed right before the dhcpcd work, so the system you're debugging is running ifupdown-ng. Its hook model is different — it uses method executors under
      /usr/libexec/ifupdown-ng/, and while the /etc/network/if-*.d/ hook dirs still fire, the env vars the compat layer exposes aren't a 1:1 match with the classic ifupdown docs (which is likely what you've been
      reading). That would explain why IFACE/METHOD/ADDRFAM/PHASE aren't showing up the way you expect. Quick confirmation: drop env > /tmp/hook-env.log at the top of your pre-up script, run ifup --verbose eth0, and
      see what's actually there. Authoritative reference is man interfaces-ng(5) and /usr/share/doc/ifupdown-ng/.

    2. Consider sidestepping hooks entirely. Since the real goal is "don't let dhcpcd touch interfaces that are configured static", you can solve it at build/boot time instead of runtime hooks — extend
      conf/turnkey.d/networking to parse /etc/network/interfaces and append denyinterfaces to /etc/dhcpcd.conf for every inet static stanza. No hook env vars, no executor quirks, and it's trivial to test.
      Cleaner than the pre-up/post-down approach and doesn't depend on ifupdown-ng internals that might shift under us later.

    3. Fallback if the above isn't enough. dhcpcd has its own hook system (/etc/dhcpcd.enter-hook, /etc/dhcpcd.exit-hook, /lib/dhcpcd/dhcpcd-hooks/) with its own env vars ($interface, $reason, $new_ip_address)
      that dhcpcd itself sets reliably — independent of whatever ifupdown/ifupdown-ng is doing.

    Happy to dig in further if you can push the WIP branch (or paste the hook script + current dhcpcd.conf + interfaces). Also re your router's slow ARP — if you want to rule it out as a variable while debugging,
    the HE tunnel I shared earlier gives you a clean IPv6 path in ~10 min.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Core - based (all apps)commonfeature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions