diff --git a/e2e/cases/ipv6-sources.sh b/e2e/cases/ipv6-sources.sh new file mode 100755 index 0000000..1b53ccc --- /dev/null +++ b/e2e/cases/ipv6-sources.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2026 Coffey Labs LLC +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# #65: a client that connects over IPv6 has to reach the server with its own +# address. On an IPv4-only project network Docker relays IPv6 connections +# through docker-proxy, and the server saw every one of them as the network's +# gateway, 172.31.253.1: SPF and DMARC were checked against that, IPv6 +# senders shared one set of bans and rate limits, and with --proxy snippets +# the gateway is an address the server is told never to ban. +# +# A second network namespace stands in for the internet, with an IPv6 and an +# IPv4 address of its own, and opens SMTP sessions to this machine. The +# server's log says which address each one came from. +# +# With OLD_REF (any installer from before the fix) the bug is shown first and +# the fixed installer then converges that install: +# OLD_REF=v2026.10.15.2 e2e/vm/run.sh e2e/cases/ipv6-sources.sh +# Without it, a fresh install is checked. +set -uo pipefail + +pass=0; fail=0 +ok() { echo " ok $*"; pass=$((pass+1)); } +bad() { echo " FAIL $*"; fail=$((fail+1)); } + +DIR=/var/lib/inbuxa +D=example.test +CLIENT6=fd00:99::2; HOST6=fd00:99::1 +CLIENT4=10.99.0.2; HOST4=10.99.0.1 +compose() { docker compose -f "$DIR/compose.yaml" "$@"; } + +ip netns add outside +ip link add v-host type veth peer name v-out +ip link set v-out netns outside +ip addr add $HOST6/64 dev v-host nodad; ip addr add $HOST4/24 dev v-host; ip link set v-host up +ip -n outside addr add $CLIENT6/64 dev v-out nodad; ip -n outside addr add $CLIENT4/24 dev v-out +ip -n outside link set v-out up; ip -n outside link set lo up + +# One SMTP session from outside to $1, then the address the server logged +# for it: the client's own, or the gateway's. +seen_as() { + local to=$1 before + before=$(compose logs server 2>&1 | wc -l) + ip netns exec outside python3 - "$to" <<'PY' >/dev/null 2>&1 +import smtplib, sys +s = smtplib.SMTP(sys.argv[1], 25, timeout=20); s.ehlo("outside.test"); s.quit() +PY + sleep 2 + compose logs server 2>&1 | tail -n +$((before + 1)) \ + | grep -oE "$CLIENT6|$CLIENT4|172\.31\.253\.1\b|fd69:6e62:7578::1\b" | head -1 +} + +check_sources() { + local got + got=$(seen_as $HOST6) + [ "$got" = "$CLIENT6" ] && ok "an IPv6 client reaches the server as itself ($got)" \ + || bad "an IPv6 client reaches the server as '${got:-nothing in the log}', not $CLIENT6" + got=$(seen_as $HOST4) + [ "$got" = "$CLIENT4" ] && ok "an IPv4 client still reaches it as itself ($got)" \ + || bad "an IPv4 client reaches the server as '${got:-nothing in the log}', not $CLIENT4" +} + +echo "==> a machine with nginx already on it" +DEBIAN_FRONTEND=noninteractive apt-get install -y -qq nginx libnginx-mod-stream openssl >/dev/null 2>&1 +systemctl is-active --quiet nginx && ok "nginx is running" || { bad "no nginx"; echo "==> $pass passed, $fail failed"; exit 1; } + +if [ -x /tmp/inbuxa-old ]; then + echo + echo "==> installed by the installer from before the fix" + OUT="$(/tmp/inbuxa-old install --domain $D --proxy snippets --install-deps --yes 2>&1)"; rc=$? + [ $rc -eq 0 ] && ok "installed (exit 0)" || { bad "exit $rc"; echo "$OUT" | tail -20 | sed 's/^/ /'; } + got=$(seen_as $HOST6) + [ "$got" = "172.31.253.1" ] && ok "the bug, shown: an IPv6 client reached the server as the gateway" \ + || bad "the old install did not show the bug: an IPv6 client was seen as '${got:-nothing}'" +fi + +echo +echo "==> installed (or converged) by this installer" +OUT="$(/tmp/inbuxa install --domain $D --proxy snippets --install-deps --yes 2>&1)"; rc=$? +echo "$OUT" | grep -v '^ |' | grep -iE "ipv6|docker|network|exit|error" | head -12 | sed 's/^/ /' +[ $rc -eq 0 ] && ok "installed (exit 0)" || { bad "exit $rc"; echo "$OUT" | tail -25 | sed 's/^/ /'; } +grep -q "enable_ipv6: true" $DIR/compose.yaml && grep -q "subnet: fd69:6e62:7578::/64" $DIR/compose.yaml \ + && ok "compose.yaml gives the project network IPv6" || bad "no IPv6 in compose.yaml" +[ "$(docker network inspect inbuxa_stack --format '{{.EnableIPv6}}' 2>/dev/null)" = true ] \ + && ok "the network Docker made has IPv6" || bad "the network inbuxa_stack has no IPv6" +v=$(docker version --format '{{.Server.Version}}') +if [ "${v%%.*}" -lt 27 ]; then + grep -q '"ip6tables": true' /etc/docker/daemon.json && grep -q '"experimental": true' /etc/docker/daemon.json \ + && ok "Docker $v: ip6tables and experimental turned on in daemon.json" || bad "Docker $v: daemon.json not changed: $(cat /etc/docker/daemon.json 2>&1)" +fi +for _ in $(seq 1 30); do curl -sf http://127.0.0.1:8081/healthz/live >/dev/null && break; sleep 2; done +check_sources + +echo +echo "==> a second run changes nothing" +OUT="$(/tmp/inbuxa install --domain $D --proxy snippets --install-deps --yes 2>&1)"; rc=$? +[ $rc -eq 0 ] && ok "second run (exit 0)" || { bad "exit $rc"; echo "$OUT" | tail -15 | sed 's/^/ /'; } +grep -q "already forwards IPv6" <<<"$OUT" && bad "the IPv6 step ran again on Docker that forwards" || ok "no IPv6 step the second time" +check_sources + +ip netns del outside +echo +echo "==> $pass passed, $fail failed" +[ "$fail" -eq 0 ] diff --git a/internal/apply/apply.go b/internal/apply/apply.go index b29517d..41af27c 100644 --- a/internal/apply/apply.go +++ b/internal/apply/apply.go @@ -50,6 +50,9 @@ const ( DefaultWebmailImage = "registry.coffeylabs.org/inbuxa/inbuxa-webmail:" + release.WebmailVersion DefaultCaddyImage = "docker.io/library/caddy:2-alpine" DefaultSubnet = "172.31.253.0/24" + // DefaultIPv6Subnet is a unique local /64 for the same network, on a + // machine with IPv6 (#65). Nothing outside the machine ever sees it. + DefaultIPv6Subnet = "fd69:6e62:7578::/64" ) // Result is what the operator is left holding. @@ -146,6 +149,9 @@ func Run(ctx context.Context, p plan.Plan, f host.Facts, log Log) (*Result, erro WebmailBind: "127.0.0.1:8080", Subnet: DefaultSubnet, } + if f.IPv6 { + stack.IPv6Subnet = DefaultIPv6Subnet + } // With --proxy snippets the operator's nginx routes 443 by name, and the // server serves its own names with its own certificates (#48). A new // install is set up that way. One from before keeps the layout it has diff --git a/internal/apply/join.go b/internal/apply/join.go index bad3ec7..8fbe504 100644 --- a/internal/apply/join.go +++ b/internal/apply/join.go @@ -143,6 +143,9 @@ func Join(ctx context.Context, p plan.Plan, f host.Facts, key string, log Log) ( Subnet: DefaultSubnet, ACMEDirectory: o.ACMEDirectory, } + if f.IPv6 { + stack.IPv6Subnet = DefaultIPv6Subnet + } if o.Shape(plan.Console) != plan.Skip { stack.ConsoleURL = consoleURL } diff --git a/internal/compose/compose.go b/internal/compose/compose.go index 5519f93..99514e9 100644 --- a/internal/compose/compose.go +++ b/internal/compose/compose.go @@ -80,12 +80,20 @@ type Stack struct { ConsoleBind string WebmailBind string - Subnet string - GatewayIP string // the project network's gateway: where the host is, seen from inside it - ServerIP string - ConsoleIP string - WebmailIP string - CaddyIP string + Subnet string + // IPv6Subnet, when set, gives the network IPv6 as well, so that a + // client connecting over IPv6 reaches the containers with its own + // address. On an IPv4-only network Docker relays such a connection + // over IPv4 from the gateway, and the server saw every IPv6 client as + // GatewayIP: SPF and DMARC failed for IPv6 senders, they shared one + // set of bans and rate limits, and GatewayIP is an address the server + // is told never to ban (#65). Empty on a machine without IPv6. + IPv6Subnet string + GatewayIP string // the project network's gateway: where the host is, seen from inside it + ServerIP string + ConsoleIP string + WebmailIP string + CaddyIP string MailPorts []int // published as-is: 25, 465, 993, 995, 4190 diff --git a/internal/compose/compose_test.go b/internal/compose/compose_test.go index eed1051..522d255 100644 --- a/internal/compose/compose_test.go +++ b/internal/compose/compose_test.go @@ -305,3 +305,24 @@ func TestProxySnippetsForJoinedFrontEndsDoNotRoute(t *testing.T) { t.Errorf("nginx-inbuxa.conf:\n%s", nginx) } } + +// #65: on a machine with IPv6 the project network carries it too, or Docker +// relays every IPv6 client from the gateway; without IPv6 it stays as it was. +func TestNetworkCarriesIPv6WhenTheMachineHasIt(t *testing.T) { + s := stack(false) + c, _ := render(t, s) + if strings.Contains(c, "enable_ipv6") || strings.Contains(c, "fd69:") { + t.Errorf("a machine without IPv6 got an IPv6 network:\n%s", c) + } + s = stack(false) + s.IPv6Subnet = "fd69:6e62:7578::/64" + c, _ = render(t, s) + for _, want := range []string{" enable_ipv6: true\n", " - subnet: 172.31.253.0/24\n - subnet: fd69:6e62:7578::/64\n"} { + if !strings.Contains(c, want) { + t.Errorf("compose.yaml lacks %q:\n%s", want, c) + } + } + if s.GatewayIP != "172.31.253.1" { + t.Errorf("the IPv4 gateway moved: %q", s.GatewayIP) + } +} diff --git a/internal/compose/templates/compose.yaml.tmpl b/internal/compose/templates/compose.yaml.tmpl index 087a53c..66b473d 100644 --- a/internal/compose/templates/compose.yaml.tmpl +++ b/internal/compose/templates/compose.yaml.tmpl @@ -183,9 +183,18 @@ services: networks: stack: +{{- if .IPv6Subnet}} + # IPv6 as well, so a client that connects over IPv6 reaches the + # containers with its own address. On an IPv4-only network Docker relays + # those connections over IPv4, and every one arrives from the gateway. + enable_ipv6: true +{{- end}} ipam: config: - subnet: {{.Subnet}} +{{- if .IPv6Subnet}} + - subnet: {{.IPv6Subnet}} +{{- end}} {{- end}} {{- if or .Server .Proxy}} diff --git a/internal/deps/deps.go b/internal/deps/deps.go index 08114ae..fd9f1a6 100644 --- a/internal/deps/deps.go +++ b/internal/deps/deps.go @@ -30,6 +30,7 @@ import ( "context" "crypto/sha256" "encoding/hex" + "encoding/json" "fmt" "io" "net/http" @@ -82,6 +83,9 @@ func For(f host.Facts, wantContainers, wantHostWebmail bool) []Need { var needs []Need if wantContainers { needs = append(needs, runtimeNeeds(f)...) + if f.IPv6 { + needs = append(needs, dockerIPv6Need(f, needs)) + } } // The webmail on the host runs on the installer's own Node, in // /opt/inbuxa/node, whatever else the machine has: the version it was @@ -192,6 +196,117 @@ func dockerNeed(f host.Facts) Need { return n } +// dockerIPv6Need turns on Docker's own IPv6 forwarding where it is off, so +// a client that connects over IPv6 reaches the containers with its own +// address. Without it docker-proxy relays the connection, and the server +// sees the project network's gateway for every IPv6 client: SPF and DMARC +// are checked against it, and bans and rate limits lump them together (#65). +// +// It is offered for Docker that is here and relays, and for Docker this run +// is about to install, whose version is not known yet; the step looks again +// once it is there and leaves a Docker that already forwards alone. Not for +// podman, which forwards both families itself, and not for a daemon.json +// that is not JSON, which the plan warns about instead: writing over a file +// that cannot be read is not a fix. +func dockerIPv6Need(f host.Facts, before []Need) Need { + installing := false + for _, n := range before { + if n.Name == "docker" && n.Fixable { + installing = true + } + } + if !installing { + if f.Runtime.Kind != "docker" || !f.Runtime.Usable || f.Runtime.ForwardsIPv6 { + return Need{} + } + cur, _ := os.ReadFile(host.DockerDaemonConfig) + if _, err := host.DockerForwardsIPv6(f.Runtime.Version, cur); err != nil { + return Need{} + } + } + n := Need{Name: "docker IPv6 forwarding", Because: "mail and web clients that connect over IPv6", Fixable: true} + if installing { + n.Actions = append(n.Actions, "if the Docker it installs relays IPv6 rather than forwarding it:") + } + n.Actions = append(n.Actions, + `set "ip6tables": true in `+host.DockerDaemonConfig+` (and "experimental": true, which Docker before 27 needs for it), keeping a copy of the file as it was`, + "restart Docker, which restarts the containers already running on this machine", + ) + n.steps = []step{{"turning on Docker's IPv6 forwarding", dockerIPv6On}} + return n +} + +func dockerIPv6On(ctx context.Context, log io.Writer) error { + out, err := exec.CommandContext(ctx, "docker", "version", "--format", "{{.Server.Version}}").Output() + if err != nil { + return fmt.Errorf("asking docker its version: %w", err) + } + version := strings.TrimSpace(string(out)) + path := host.DockerDaemonConfig + cur, err := os.ReadFile(path) + if err != nil && !os.IsNotExist(err) { + return err + } + on, err := host.DockerForwardsIPv6(version, cur) + if err != nil { + return err + } + if on { + fmt.Fprintf(log, " Docker %s already forwards IPv6\n", version) + return nil + } + cfg := map[string]any{} + if len(strings.TrimSpace(string(cur))) > 0 { + if err := json.Unmarshal(cur, &cfg); err != nil { + return err + } + } + cfg["ip6tables"] = true + if host.DockerMajor(version) < 27 { + cfg["experimental"] = true + } + next, err := json.MarshalIndent(cfg, "", " ") + if err != nil { + return err + } + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { + return err + } + if cur != nil { + backup := path + ".before-inbuxa" + if _, err := os.Stat(backup); os.IsNotExist(err) { + if err := os.WriteFile(backup, cur, 0o644); err != nil { + return err + } + fmt.Fprintf(log, " the file as it was is in %s\n", backup) + } + } + if err := writeFile(path, append(next, '\n')); err != nil { + return err + } + if err := run(ctx, log, "systemctl", "restart", "docker"); err != nil { + // A daemon that will not start on the new file is worse than one + // that relays IPv6: put the old one back and start it on that. + if cur != nil { + _ = writeFile(path, cur) + } else { + _ = os.Remove(path) + } + _ = run(ctx, log, "systemctl", "restart", "docker") + return fmt.Errorf("docker did not restart with ip6tables on, so %s is back as it was: %w", path, err) + } + return nil +} + +// writeFile replaces path in one step, so a reader never finds half a file. +func writeFile(path string, b []byte) error { + tmp := path + ".tmp" + if err := os.WriteFile(tmp, b, 0o644); err != nil { + return err + } + return os.Rename(tmp, path) +} + // composeNeed is the same plugin whichever runtime is underneath: compose // speaks the Docker API, and podman serves it. func composeNeed(f host.Facts) Need { diff --git a/internal/deps/ipv6_test.go b/internal/deps/ipv6_test.go new file mode 100644 index 0000000..777ca4f --- /dev/null +++ b/internal/deps/ipv6_test.go @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: 2026 Coffey Labs LLC +// SPDX-License-Identifier: AGPL-3.0-or-later + +package deps + +import ( + "testing" + + "git.coffeylabs.org/inbuxa/inbuxa-installer/internal/host" +) + +func hasNeed(needs []Need, name string) bool { + for _, n := range needs { + if n.Name == name { + return true + } + } + return false +} + +// #65: Docker's IPv6 forwarding is offered where Docker relays IPv6 and the +// machine has it, and for a Docker this run installs; never for podman, a +// machine without IPv6, or Docker that already forwards. +func TestDockerIPv6Offered(t *testing.T) { + const want = "docker IPv6 forwarding" + relays := host.Facts{IPv6: true, Runtime: host.Runtime{Kind: "docker", Present: true, Usable: true, Version: "26.1.5+dfsg1", Compose: "v2"}} + if !hasNeed(For(relays, true, false), want) { + t.Error("not offered for Docker 26 that relays IPv6") + } + if hasNeed(For(relays, false, false), want) { + t.Error("offered with nothing in containers") + } + noV6 := relays + noV6.IPv6 = false + if hasNeed(For(noV6, true, false), want) { + t.Error("offered on a machine without IPv6") + } + forwards := relays + forwards.Runtime.ForwardsIPv6 = true + if hasNeed(For(forwards, true, false), want) { + t.Error("offered for Docker that already forwards") + } + podman := host.Facts{IPv6: true, OS: host.OSInfo{Family: "rhel"}, Runtime: host.Runtime{Kind: "podman", Present: true, Usable: true, ForwardsIPv6: true}} + if hasNeed(For(podman, true, false), want) { + t.Error("offered for podman") + } + fresh := host.Facts{IPv6: true, OS: host.OSInfo{ID: "debian", Family: "debian"}} + needs := For(fresh, true, false) + if !hasNeed(needs, "docker") || !hasNeed(needs, want) { + t.Errorf("a Debian machine with no runtime: got %v", needs) + } + if needs[len(needs)-1].Name != want { + t.Error("IPv6 forwarding is not offered after Docker itself") + } +} diff --git a/internal/host/host.go b/internal/host/host.go index 2bb1c69..0dd14cc 100644 --- a/internal/host/host.go +++ b/internal/host/host.go @@ -14,6 +14,7 @@ package host import ( "bufio" "context" + "encoding/json" "errors" "fmt" "net" @@ -41,6 +42,13 @@ type Facts struct { DiskFreeGB int // on the filesystem that would hold the install MemoryMB int Existing string // path of a previous install's state file, or "" + + // IPv6 is whether this kernel has IPv6 turned on. When it does, clients + // can connect over it, and the project network has to carry it too: + // Docker relays an IPv6 connection to an IPv4-only container from its + // own gateway, so every IPv6 client arrives from one private address + // (#65). + IPv6 bool } // OSInfo is the distribution, as os-release describes it. @@ -65,6 +73,14 @@ type Runtime struct { Socket string // for podman, the API socket compose is pointed at Why string // why it is unusable, in a sentence fit to show someone + // ForwardsIPv6 is whether the runtime forwards a published port's IPv6 + // connections to a container with the client's own address. Podman + // does. Docker does from 27 on, unless turned off; before 27 only with + // ip6tables turned on, which is experimental there. Without it Docker + // relays them through docker-proxy, and the container sees the + // gateway instead of the client. + ForwardsIPv6 bool + // What is missing, named rather than described, so the caller does not // have to read Why to decide what to do. Reporting only the first thing // in the way meant fixing one of them and being told about the next. @@ -140,6 +156,7 @@ func Survey(ctx context.Context) Facts { Node: surveyNode(ctx), Glibc: surveyGlibc(ctx), MemoryMB: memoryMB(), + IPv6: kernelIPv6(), } if u, err := user.Current(); err == nil { f.Root = u.Uid == "0" @@ -244,6 +261,8 @@ func surveyDocker(ctx context.Context) Runtime { } r.Usable = true r.Version = strings.TrimSpace(string(out)) + daemon, _ := os.ReadFile(DockerDaemonConfig) + r.ForwardsIPv6, _ = DockerForwardsIPv6(r.Version, daemon) if err := exec.CommandContext(ctx, bin, "compose", "version").Run(); err == nil { r.Compose = "v2" @@ -305,10 +324,60 @@ func surveyPodman(ctx context.Context) Runtime { r.Why = "the compose plugin is not installed" default: r.Usable = true + // Netavark forwards published ports with nftables for both + // families, so the container sees the client's own address. + r.ForwardsIPv6 = true } return r } +// DockerDaemonConfig is the Docker daemon's own configuration file. +const DockerDaemonConfig = "/etc/docker/daemon.json" + +// DockerForwardsIPv6 works out from the engine's version and its +// daemon.json whether Docker forwards IPv6 connections to containers itself +// (ip6tables) rather than relaying them. ip6tables is on by default from +// Docker 27; before that it is off, and turning it on also takes +// "experimental", without which the daemon refuses to start. +// +// The error is for a daemon.json that is not JSON: then nothing can be said, +// and nothing should be written over it either. +func DockerForwardsIPv6(version string, daemonJSON []byte) (bool, error) { + cfg := map[string]any{} + if len(strings.TrimSpace(string(daemonJSON))) > 0 { + if err := json.Unmarshal(daemonJSON, &cfg); err != nil { + return false, fmt.Errorf("%s: %w", DockerDaemonConfig, err) + } + } + on, set := cfg["ip6tables"].(bool) + if DockerMajor(version) >= 27 { + return !set || on, nil + } + exp, _ := cfg["experimental"].(bool) + return set && on && exp, nil +} + +// DockerMajor is the major number of an engine version such as +// "26.1.5+dfsg1", or 0 when there is none to read. +func DockerMajor(version string) int { + major, _, _ := strings.Cut(strings.TrimPrefix(strings.TrimSpace(version), "v"), ".") + n, err := strconv.Atoi(major) + if err != nil { + return 0 + } + return n +} + +// kernelIPv6 is whether IPv6 is on: the module is loaded (if_inet6 exists +// only then) and not turned off for every interface. +func kernelIPv6() bool { + if _, err := os.Stat("/proc/net/if_inet6"); err != nil { + return false + } + b, err := os.ReadFile("/proc/sys/net/ipv6/conf/all/disable_ipv6") + return err != nil || strings.TrimSpace(string(b)) != "1" +} + // ComposePluginPath is where this installer puts the compose plugin, and // where it looks for one it put there before. The same file serves docker // and podman. diff --git a/internal/host/ipv6_test.go b/internal/host/ipv6_test.go new file mode 100644 index 0000000..995eecb --- /dev/null +++ b/internal/host/ipv6_test.go @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: 2026 Coffey Labs LLC +// SPDX-License-Identifier: AGPL-3.0-or-later + +package host + +import "testing" + +// Measured on Debian 13's docker.io 26.1.5 (#65): without ip6tables an IPv6 +// client of a published port reached the container as the gateway; with +// "ip6tables" and "experimental" on, as itself; with "ip6tables" alone the +// daemon would not start. +func TestDockerForwardsIPv6(t *testing.T) { + for _, c := range []struct { + version, daemon string + want bool + }{ + {"26.1.5+dfsg1", "", false}, + {"26.1.5+dfsg1", `{"ip6tables": true}`, false}, + {"26.1.5+dfsg1", `{"ip6tables": true, "experimental": true}`, true}, + {"27.0.3", "", true}, + {"29.0.1", `{"log-driver": "journald"}`, true}, + {"29.0.1", `{"ip6tables": false}`, false}, + {"", "", false}, + } { + got, err := DockerForwardsIPv6(c.version, []byte(c.daemon)) + if err != nil || got != c.want { + t.Errorf("Docker %q with %q: got %v, %v; want %v", c.version, c.daemon, got, err, c.want) + } + } + if _, err := DockerForwardsIPv6("29.0.1", []byte("{not json")); err == nil { + t.Error("a daemon.json that is not JSON was read as something") + } +} + +func TestDockerMajor(t *testing.T) { + for v, want := range map[string]int{"26.1.5+dfsg1": 26, "v29.0.1": 29, "28": 28, "": 0, "dev": 0} { + if got := DockerMajor(v); got != want { + t.Errorf("DockerMajor(%q) = %d, want %d", v, got, want) + } + } +} diff --git a/internal/plan/plan.go b/internal/plan/plan.go index 35daf75..20d2af3 100644 --- a/internal/plan/plan.go +++ b/internal/plan/plan.go @@ -272,6 +272,9 @@ func Build(f host.Facts, o Options) (Plan, error) { // tarball. The installer says what it would do about each and does it when // told, rather than handing the operator a chore and calling it an error. p.Needs = deps.For(f, wantContainers, wantHostWebmail) + if w := ipv6Warning(f, wantContainers, o.InstallDeps); w != "" { + p.Warnings = append(p.Warnings, w) + } for _, c := range []Component{Server, Console, Webmail} { s := o.Shape(c) @@ -461,6 +464,24 @@ func Build(f host.Facts, o Options) (Plan, error) { // covered says whether a cell's unavailability is one of the things the // installer offered to fix. +// ipv6Warning is what the operator should hear about IPv6 when Docker here +// relays it and this run will not change that: every client that connects +// over IPv6 would reach the suite from one private address (#65). +func ipv6Warning(f host.Facts, wantContainers, installDeps bool) string { + if !wantContainers || !f.IPv6 || f.Runtime.Kind != "docker" || !f.Runtime.Usable || f.Runtime.ForwardsIPv6 { + return "" + } + const why = "every client that connects over IPv6 would reach the suite from one private address, so mail from IPv6 senders fails SPF and their bans and rate limits are shared" + cur, _ := os.ReadFile(host.DockerDaemonConfig) + if _, err := host.DockerForwardsIPv6(f.Runtime.Version, cur); err != nil { + return fmt.Sprintf("Docker %s relays IPv6 rather than forwarding it, and %v: until \"ip6tables\" is on there, %s", f.Runtime.Version, err, why) + } + if installDeps { + return "" + } + return fmt.Sprintf("Docker %s relays IPv6 rather than forwarding it: %s. --install-deps turns its IPv6 forwarding on (and restarts Docker); or keep the mail host's AAAA record out of DNS", f.Runtime.Version, why) +} + func covered(needs []deps.Need, c Component, s Shape) bool { want := map[string]bool{} switch {