Fix/bind addr ipv6 fallback - #219
pinguinfuss wants to merge 4 commits into
Conversation
Commit 84a119f switched --bind-addr to "[::]:8443" for dual-stack, but binding fails with EAFNOSUPPORT when IPv6 is disabled in the kernel, leaving code-server unreachable. Detect IPv6 via /proc/net/if_inet6 and fall back to 0.0.0.0:8443 when it is unavailable.
There was a problem hiding this comment.
Thanks for opening this pull request! Be sure to follow the pull request template!
|
Relates to #218 |
|
One suggestion: it might be useful to adjust the BIND_ADDR from outside the container by setting an environment parameter. It's only two more lines of code: in File root/etc/s6-overlay/s6-rc.d/svc-code at line 21 Updates for README.md and an example showing how to handle it: |
|
This pull request has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Keep it open |
|
Hope it will get merged, im sick of manual fixing after each version... |
|
@PLCHome: should be in the PR now. |
|
im unsure why we should entertain people disabling an entire protocol stack in 2026? the tl;dr here is that while disabling ipv6 may have been suggested in the early 2000s by uneducated network admins, there is absolutely no value in it . it does not increase security, it breaks things, and it clearly adds administrative overhead. I will leave this open for the other team members to chime in, since they're all ipv4 cult (and yet still dont suggest entirely disabling protocol stacks) |
|
Let me explain the background a bit more clearly: From a security perspective, there is an additional angle: a strict restriction of the IPv6 address space (more secure), or |
|
I'm surprised this is running on your 32bit raspberry pi as we haven't built though I ages for 3 years now. |
|
Sorry, it's a 64-bit Debian GNU/Linux 12 (bookworm) system using the linuxserver/code-server image on Docker. But it only runs with this change. |
this is the issue, as i mentioned there hasn't been a valid reason in 20+ years to disable it at the OS level even 20years ago, it was mostly just misunderstood there is no need to try to convince me though, i cannot be convinced disabling the stack at the os/host level has value. The other team members will decide whether this gets merged. (which will also mean they have to do the same on numerous other containers for consistency if they decide to approve it) |
|
It won't start without the change: With the change, the IP range has been switched to IPv4, and it is starting up. But I prefer only one interface: I just tried it again with the current version |
|
I don't think you understand what we are trying to tell you. What we're saying is that you SHOULD NOT be disabling ipv6 on your rpi. That is the reason the container is not starting as you are experiencing. We do not support disabling ipv6 at the OS level. |
Description:
Commit 84a119f (#216) switched
--bind-addrto"[::]:8443"so the service listens on both IPv4 and IPv6 via dual-stack. This works fine when an IPv6 stack is present (even on IPv4-only networks), but it fails outright when IPv6 is disabled at the kernel level (e.g.ipv6.disable=1, kernel built withoutCONFIG_IPV6, or the module not loaded). In that case there is noAF_INET6socket family, so binding to[::]fails withEAFNOSUPPORTand code-server never starts — the container becomes unreachable.This PR detects IPv6 availability at startup via the presence of
/proc/net/if_inet6(the standard indicator that the kernel has IPv6 support) and chooses the bind address accordingly:[::]:8443(dual-stack, unchanged behaviour from listen on both ipv4 and ipv6 even when running container as root #216)0.0.0.0:8443(IPv4 fallback)Both the root and non-root exec paths use the shared
BIND_ADDRvariable.Benefits of this PR and context:
Restores the ability to run the container on hosts/kernels with IPv6 disabled, which regressed after #216, while fully preserving the dual-stack behaviour that #216 introduced for everyone else. No configuration or environment variables are required — the correct address is selected automatically.
How Has This Been Tested?
Verified in a container inheriting a host kernel with IPv6 fully disabled
(
/proc/net/if_inet6and/proc/sys/net/ipv6absent):[::]:8443fails with[Errno 97] Address family not supported by protocol(reproduces the regression).0.0.0.0:8443succeeds.[[ -e /proc/net/if_inet6 ]]correctly evaluates false, so the script selects the0.0.0.0fallback.On a normal dual-stack host
/proc/net/if_inet6is present and the script keeps[::]:8443, so existing IPv4+IPv6 behaviour is unchanged.Source / References:
--bind-addr "[::]:8443")(only IPv6-less networks with the stack still present).
Container does not work on host with ipv6 disabled docker-swag#92
Closes #218