Skip to content

Dhcpcd ipv6 support#102

Open
JedMeister wants to merge 7 commits intoturnkeylinux:masterfrom
JedMeister:dhcpcd-ipv6-support
Open

Dhcpcd ipv6 support#102
JedMeister wants to merge 7 commits intoturnkeylinux:masterfrom
JedMeister:dhcpcd-ipv6-support

Conversation

@JedMeister
Copy link
Copy Markdown
Member

@JedMeister JedMeister commented Apr 10, 2026

Copy of @marcos-mendez's #101 PR - see that for full details of the IPv6 update.

This PR:

  • amends the last commit to update the gitgnore file and remove build assets (that will now be ignored post the updated gitignore).
  • increases the default size of the window for nicer display of ipv6 addresses
  • reformats the text to get it all on the one screen where possible.

PopSolutions and others added 6 commits March 24, 2026 16:44
- ifutil.py: Add retry loop (10s timeout) in set_dhcp() for non-blocking
  DHCP clients like dhcpcd. The previous code checked for an IP address
  immediately after ifup returned, but dhcpcd forks and assigns the
  address asynchronously (~3s delay).

- ifutil.py: Add get_ipv6conf() to retrieve global-scope IPv6 address
  and prefix length via 'ip -6 addr show'.

- confconsole.py: Display IPv6 address in both the main services screen
  and the networking configuration screen when available.

Tested on Proxmox LXC unprivileged container (Moodle v19, Trixie)
with dhcpcd as the sole DHCP client (dual-stack DHCPv4/DHCPv6).
_get_default_nic() only checked IPv4 via get_ipconf(), causing
confconsole to report 'Networking is not yet configured' on
IPv6-only hosts despite having a valid global address.

Add get_ipv6conf() fallback in _validip(): if no valid IPv4 is
found, check for a global-scope IPv6 address before declaring
the interface unconfigured.

This enables IPv6-first deployments to pass the network check
without requiring an IPv4 address.
Pass IPv6 address as $ip6addr to services.txt template instead of
appending it after substitution. Uses safe_substitute so appliances
without $ip6addr in their services.txt are unaffected.

Ref: turnkeylinux/tracker#1658
@JedMeister JedMeister requested a review from OnGle April 14, 2026 04:51
@JedMeister
Copy link
Copy Markdown
Member Author

Let me know what you think @OnGle


hostname = netinfo.get_hostname().upper()

ipv6_addr, ipv6_prefix = ifutil.get_ipv6conf(ifname)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Jed,

get_ipv6conf(ifname) is called twice in usage() — once around line 513 (before safe_substitute) and again around line 527 (where it's actually used for the IPv6 Web/SSH display). The first call result is never referenced, so it's a redundant subprocess call on every screen render.

Two options:

  1. Just remove the first call.
  2. Keep it and pass ip6addr into safe_substitute() so appliance services.txt templates can reference $ip6addr in the future:
text = Template(t).safe_substitute(
    appname=self.appname,
    hostname=hostname,
    ipaddr=ip_addr,
    ip6addr=ipv6_addr or '',
)

Then the second call becomes unnecessary.

I'd lean toward option 2 — it's forward-compatible and safe_substitute won't break anything if the variable isn't used in the template.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to start review

Copy link
Copy Markdown
Member

@marcos-mendez marcos-mendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry got a litttle messy my comment but here it is


hostname = netinfo.get_hostname().upper()

ipv6_addr, ipv6_prefix = ifutil.get_ipv6conf(ifname)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to start review

@JedMeister
Copy link
Copy Markdown
Member Author

Thanks @marcos-mendez 😁

Looking closer it's called 4 times...!

First @ 334 in _get_default_nic()
Then @ 444 in _get_ifconftext()
Then twice in usage() as you noted.

I've removed that last one and moved hostname = netinfo.get_hostname().upper() below it - so all the IP stuff is together.

TBH I think now we're making ipv6 a "first class citizen" refactoring the whole layout would be nice. As an aside, @OnGle & I have often talked about possibly ditching dialog altogether. But all of that's for another day...

@JedMeister
Copy link
Copy Markdown
Member Author

FYI I've just packaged this and pushed it to the TKL trixie-testing apt repo - it's version 2.2.0rc3+7+gd67ab42.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants