Skip to content

Fix/bind addr ipv6 fallback#219

Open
pinguinfuss wants to merge 2 commits into
linuxserver:masterfrom
pinguinfuss:fix/bind-addr-ipv6-fallback
Open

Fix/bind addr ipv6 fallback#219
pinguinfuss wants to merge 2 commits into
linuxserver:masterfrom
pinguinfuss:fix/bind-addr-ipv6-fallback

Conversation

@pinguinfuss

Copy link
Copy Markdown

linuxserver.io


  • I have read the contributing guideline and understand that I have made the correct modifications

Description:

Commit 84a119f (#216) switched --bind-addr to "[::]: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 without CONFIG_IPV6, or the module not loaded). In that case there is no AF_INET6 socket family, so binding to [::] fails with EAFNOSUPPORT and 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:

Both the root and non-root exec paths use the shared BIND_ADDR variable.

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_inet6 and /proc/sys/net/ipv6 absent):

  • Binding to [::]:8443 fails with [Errno 97] Address family not supported by protocol (reproduces the regression).
  • Binding to 0.0.0.0:8443 succeeds.
  • [[ -e /proc/net/if_inet6 ]] correctly evaluates false, so the script selects the 0.0.0.0 fallback.

On a normal dual-stack host /proc/net/if_inet6 is present and the script keeps [::]:8443, so existing IPv4+IPv6 behaviour is unchanged.

Source / References:

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for opening this pull request! Be sure to follow the pull request template!

@pinguinfuss

Copy link
Copy Markdown
Author

Relates to #218

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants