Skip to content

Migrate to netfilter (nftables) #9449

Closed
concourse/concourse-docker
#88

Description

@taylorsilva

Summary

We should move off of invoking iptables in our containerd runtime and use nftables (netfilter) instead. iptables has been labelled as legacy for MANY years now and are not enabled on newer kernels. Also seeing errors like this more often in our containerd integration tests:

starting task: network add: cni net setup: 
  plugin type="bridge" failed (add):
  failed to list chains: running [/usr/bin/ip6tables -t nat -S --wait]:
  exit status 3: ip6tables v1.8.11 (legacy):
  can't initialize ip6tables table `nat': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.

Will probably change behaviour to detect if nftables is present and prefer using it over iptables, with iptables being present as a fallback.

Context

Past issues:

Docs for research:
https://wiki.nftables.org/wiki-nftables/index.php/Moving_from_iptables_to_nftables
https://github.com/google/nftables

Pinned by taylorsilva

Activity

  1. added theissue type on Feb 2, 2026
  2. moved this from Icebox to In progress in Concourse Roadmapon Feb 2, 2026
  3. changed the title [-]Migrate to nftables[/-] [+]Migrate to netfilter (nftables)[/+] on Feb 2, 2026
  4. taylorsilva commented on Feb 2, 2026

    @taylorsilva
    MemberAuthor

    Reviewing old issues, it looks like we thought about using the CNI plugin for firewalld. firewalld is present on most major linux distributions now. https://firewalld.org/ lists:

    • RHEL 7 and newer
    • CentOS 7 and newer
    • Fedora 18 and newer
    • SUSE 15 and newer
    • OpenSUSE 15 and newer

    There are some big ones missing from this list, like Ubuntu and Debian. Ubuntu uses ufw and Debian appears to not come with anything on top of netfilter. You can install firewalld easily on all major distributions. Vito noticed the same thing #5136 (comment) and he referenced the nftables go pkg from Google too. Funny, looks like the landscape hasn't changed that much.

    I think I prefer directly building on nftables instead of on firewalld right now. Doesn't add a pre-req when setting up a Worker. Going to start proceeding in that direction using the Go package from Google: https://github.com/google/nftables

  5. taylorsilva commented on Feb 2, 2026

    @taylorsilva
    MemberAuthor

    Looking at

    g, err := goiptables.New()

    I realized we can specify the iptables binary to use. I tried swapping in iptables-nft to see if things would just work. Sadly something behaviourally breaks and the worker/runtime/integration tests fail. Going to keep looking into this path as it would be the least amount of work if I can get it working.

  6. taylorsilva commented on Feb 2, 2026

    @taylorsilva
    MemberAuthor

    Ah, well looking at open issues seems to have answered this for me: coreos/go-iptables#101

    Looks like this lib doesn't work with iptables-nft right now! Last update was also 2 years ago so this repo is looking majorly abandoned! Last commit is from a user that no longer works at coreos.

    Leaving this path and going back to working with Google's nftables package.

  7. taylorsilva commented on Feb 3, 2026

    @taylorsilva
    MemberAuthor

    Might be blocked on making this happen. Right now we do use the CNI firewall plugin:

    // Default firewall plugin configuration
    //
    defaultFirewallPlugin = FirewallPlugin{
    Plugin: Plugin{"firewall"},
    IPTablesChainName: ipTablesAdminChainName,
    }

    Docs for that are here: https://www.cni.dev/plugins/current/meta/firewall/
    and they state:

    This plugin supports multiple firewall backends that implement the desired functionality. Available backends include iptables and firewalld and may be selected with the backend key. If no backend key is given, the plugin will use firewalld if the service exists on the D-Bus system bus. If no firewalld service is found, it will fall back to iptables.

    We don't specify which backend to use. Right now on the workers I have access to, most of them don't have firewalld installed so it falls back to using iptables. Regardless, we should be in-sync with whatever the plugin decides to do, using either iptables or nftables. Using both is possible but not recommended:

    Beware of using both the nft and the legacy tools at the same time. That means using both x_tables and nf_tables kernel subsystems at the same time, and could lead to unexpected results.

    Source: https://wiki.nftables.org/wiki-nftables/index.php/Moving_from_iptables_to_nftables

    It seems like we'd be fighting the firewall plugin potentially and this might already be the case.

    Funny, there was a PR to add support: containernetworking/plugins#462
    But the author closed the PR and has an unmaintained fork here: https://github.com/greenpau/cni-plugins/tree/main


    I reviewed our usage of iptables and it's actually quite limited. We basically use it to do some network setup. It was most recently modified to add the hermetic value to tasks, which drops all network traffic in and out of the container. All usage is in this file: https://github.com/concourse/concourse/blob/1dfdf121f7245360722f693ccd46d5bd15e6ece5/worker/runtime/cni_network.go


    Not sure which direction to go here. Would be nice if the firewall CNI plugin used nftables but they don't. Someone needs to PR it.

  8. taylorsilva commented on Feb 4, 2026

    @taylorsilva
    MemberAuthor

    Initial motivation for this was seeing the containerd-integration tests failing because some of the iptable modules weren't loaded. For some reason that's not the case anymore, so I'm putting this issue into the backlog.

    I think we are blocked on doing this until the CNI firewall plugin has nftables support. Right now we do rely on using the iptables backend with the firewall plugin. All the things we do rely on us hooking into the iptablesAdminChainName. If we aren't in sync with the firewall plugin, then our networking stuff will break.

    Other interesting doc:
    https://github.com/kubernetes-sigs/knftables/blob/v0.0.19/docs/iptables-porting.md

    The other tools in https://github.com/containernetworking/plugins/ use https://github.com/kubernetes-sigs/knftables (sigs.k8s.io/knftables) for nftables. That lib uses the nft cli.

  9. moved this from In progress to Icebox in Concourse Roadmapon Feb 4, 2026
  10. justinkoreska commented on Feb 13, 2026

    @justinkoreska

    FYI we are trying to deploy Concourse via Helm on a Talos Kubernetes cluster and the worker pods fail with a similar error:

    containerd-garden-backend exited with error: setup host network failed: create chain or flush if exists failed: running [/usr/bin/iptables -t filter -N CONCOURSE-OPERATOR --wait]: exit status 3: iptables v1.8.11 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
    Perhaps iptables or your kernel needs to be upgraded.
    

    I assume this is because Talos now uses nftables and does not support iptables.

  11. taylorsilva commented on Feb 13, 2026

    @taylorsilva
    MemberAuthor

    I assume this is because Talos now uses nftables and does not support iptables.

    Yup, that would be why. As I mentioned though, we're blocked on the firewall CNI plugin not supporting nftables.

  12. Tyraeis commented on May 16, 2026

    @Tyraeis

    I ran into the same issue as @justinkoreska trying to run worker pods on Talos and figured I'd see if I could hack together a solution. I ended up getting the workers to run by creating a custom version of the concourse/concourse docker container that replaces iptables/ip6tables with iptables-nft + iptables-wrappers:

    --- a/Dockerfile
    +++ b/Dockerfile
    @@ -22,8 +22,8 @@ RUN apk --no-cache add \
         dumb-init \
         iproute2 \
         file \
    -    iptables \
    -    ip6tables \
    +    iptables-nft \
    +    iptables-wrappers \
         cmd:losetup \
         coreutils \
         cmd:grep \
    

    (I also had to set the sysctl user.max_user_namespaces to a nonzero value, but that's unrelated)

    I haven't done very thorough testing with the setup, but I was able to successfully run a pipeline so it at least seems to be able to run containers.

    Rereading this thread, I noticed that @taylorsilva already tried iptables-nft:

    I realized we can specify the iptables binary to use. I tried swapping in iptables-nft to see if things would just work. Sadly something behaviourally breaks and the worker/runtime/integration tests fail. Going to keep looking into this path as it would be the least amount of work if I can get it working.

    I tried running the worker/runtime/integration tests myself on my Arch Linux desktop to see if I also saw failures (using the iptables package, which is actually iptables-nft under the hood). I got an error with the MASQUERADE flag at first, but running sudo modprobe nft_masq on the host machine fixed it. After that change, the tests passed:

    $ docker run -v ./concourse:/src -it --privileged --entrypoint /bin/bash concourse/dev
    bash-5.3# apk update
    fetch https://apk.cgr.dev/chainguard/x86_64/APKINDEX.tar.gz
     [https://apk.cgr.dev/chainguard]
    OK: 186658 distinct packages available
    bash-5.3# apk del iptables ip6tables
    (1/3) Purging ip6tables (1.8.13-r3)
    (2/3) Purging iptables (1.8.13-r3)
    (3/3) Installing xtables (1.8.11-r32)
    Executing busybox-1.37.0-r57.trigger
    OK: 567 MiB in 84 packages
    bash-5.3# apk add iptables-nft iptables-wrappers
    (1/4) Purging xtables (1.8.11-r32)
    (2/4) Installing iptables (1.8.13-r3)
    (3/4) Installing iptables-nft (1.8.13-r3)
    (4/4) Installing iptables-wrappers (2-r14)
    Executing busybox-1.37.0-r57.trigger
    OK: 569 MiB in 86 packages
    bash-5.3# iptables -V
    iptables v1.8.13 (nf_tables)
    bash-5.3# cd /src
    bash-5.3# go test -v ./worker/runtime/integration/
    === RUN   TestSuite
    === RUN   TestSuite/TestAttach
    === RUN   TestSuite/TestAttachToFinishedProcess
    === RUN   TestSuite/TestAttachToUnknownProc
    === RUN   TestSuite/TestContainerAllowsHostAccess
    === RUN   TestSuite/TestContainerBlocksHostAccess
    === RUN   TestSuite/TestContainerCreateRunStopedDestroy
    === RUN   TestSuite/TestContainerNetworkEgress
    === RUN   TestSuite/TestContainerNetworkEgressWithRestrictedNetworks
    === RUN   TestSuite/TestContainerNetworkHosts
    === RUN   TestSuite/TestCustomDNS
    === RUN   TestSuite/TestGracefulStop
    === RUN   TestSuite/TestHermeticContainerNetworkEgress
    === RUN   TestSuite/TestMaxContainers
    === RUN   TestSuite/TestNetworkMountsAreRemoved
    === RUN   TestSuite/TestNewContainerEnforcesTimeoutOnTask
    === RUN   TestSuite/TestPing
    === RUN   TestSuite/TestPropertiesGetChunked
    === RUN   TestSuite/TestRequestTimeoutZero
    === RUN   TestSuite/TestRunPrivileged
    === RUN   TestSuite/TestRunRecoversFromTaskNotFoundErr
    === RUN   TestSuite/TestRunUnprivileged
    === RUN   TestSuite/TestRunWithTerminalStdinClosed
    === RUN   TestSuite/TestRunWithoutTerminalStdinReturnsEOF
    === RUN   TestSuite/TestUngracefulStop
    --- PASS: TestSuite (56.58s)
        --- PASS: TestSuite/TestAttach (8.76s)
        --- PASS: TestSuite/TestAttachToFinishedProcess (7.30s)
        --- PASS: TestSuite/TestAttachToUnknownProc (0.68s)
        --- PASS: TestSuite/TestContainerAllowsHostAccess (0.71s)
        --- PASS: TestSuite/TestContainerBlocksHostAccess (0.79s)
        --- PASS: TestSuite/TestContainerCreateRunStopedDestroy (0.77s)
        --- PASS: TestSuite/TestContainerNetworkEgress (0.65s)
        --- PASS: TestSuite/TestContainerNetworkEgressWithRestrictedNetworks (0.66s)
        --- PASS: TestSuite/TestContainerNetworkHosts (0.76s)
        --- PASS: TestSuite/TestCustomDNS (0.69s)
        --- PASS: TestSuite/TestGracefulStop (11.72s)
        --- PASS: TestSuite/TestHermeticContainerNetworkEgress (6.77s)
        --- PASS: TestSuite/TestMaxContainers (0.70s)
        --- PASS: TestSuite/TestNetworkMountsAreRemoved (0.66s)
        --- PASS: TestSuite/TestNewContainerEnforcesTimeoutOnTask (1.30s)
        --- PASS: TestSuite/TestPing (0.28s)
        --- PASS: TestSuite/TestPropertiesGetChunked (2.34s)
        --- PASS: TestSuite/TestRequestTimeoutZero (0.35s)
        --- PASS: TestSuite/TestRunPrivileged (0.65s)
        --- PASS: TestSuite/TestRunRecoversFromTaskNotFoundErr (1.14s)
        --- PASS: TestSuite/TestRunUnprivileged (1.06s)
        --- PASS: TestSuite/TestRunWithTerminalStdinClosed (6.36s)
        --- PASS: TestSuite/TestRunWithoutTerminalStdinReturnsEOF (0.81s)
        --- PASS: TestSuite/TestUngracefulStop (0.65s)
    PASS
    ok      github.com/concourse/concourse/worker/runtime/integration       56.587s
    bash-5.3# 
    

    For reference, this is what I get if I use the legacy iptables backend:

    $ docker run -v ./concourse:/src -it --privileged --entrypoint /bin/bash concourse/dev
    bash-5.3# iptables -V
    iptables v1.8.13 (legacy)
    bash-5.3# cd /src
    bash-5.3# go test -v ./worker/runtime/integration/
    === RUN   TestSuite
    === RUN   TestSuite/TestAttach
    === NAME  TestSuite
        integration_test.go:136: 
                    Error Trace:    github.com/concourse/concourse/worker/runtime/integration/integration_test.go:136
                                                            github.com/stretchr/[email protected]/suite/suite.go:191
                    Error:          Received unexpected error:
                                    setup host network failed: create chain or flush if exists failed: running [/usr/bin/iptables -t filter -N CONCOURSE-OPERATOR --wait]: exit status 3: iptables v1.8.13 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
                                    Perhaps iptables or your kernel needs to be upgraded.
                    Test:           TestSuite
    === NAME  TestSuite/TestAttach
        testing.go:1913: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test
    === NAME  TestSuite
        integration_test.go:78: 
                    Error Trace:    github.com/concourse/concourse/worker/runtime/integration/integration_test.go:78
                                                            github.com/concourse/concourse/worker/runtime/integration/integration_test.go:109
                                                            github.com/stretchr/[email protected]/suite/suite.go:216
                                                            runtime/panic.go:694
                                                            testing/testing.go:2112
                                                            github.com/stretchr/[email protected]/suite/suite.go:235
                                                            github.com/stretchr/[email protected]/suite/suite.go:225
                                                            github.com/concourse/concourse/worker/runtime/integration/suite_test.go:56
                    Error:          Received unexpected error:
                                    signal: terminated
                    Test:           TestSuite
    --- FAIL: TestSuite (0.01s)
        --- FAIL: TestSuite/TestAttach (0.01s)
    FAIL
    FAIL    github.com/concourse/concourse/worker/runtime/integration       0.015s
    FAIL
    bash-5.3# 
    

    Not sure if there's something different with my setup or if I'm missing something, but this suggests it might be possible to migrate via iptables-nft without having to wait for the firewall CNI plugin?

  13. taylorsilva commented on May 20, 2026

    @taylorsilva
    MemberAuthor

    Thanks for the sharing your research. I'll take a look into this again. Wish I had recorded the errors I ran into when I initially tried using iptables-nft.

  14. moved this from Icebox to Backlog in Concourse Roadmapon May 20, 2026
  15. vfx1b commented on May 29, 2026

    @vfx1b

    Seeing this error with a concourse cluster deployed to EKS. Worked around it by running modprobe ip_tables on the affected "newer" node.

  16. rfpludwick commented on Aug 5, 2026

    @rfpludwick

    Running on Raspbian/Debian Trixie now, and I've started to see the iptables errors. Tried modprobe ip_tables with no luck. I tried downgrading to legacy and kube-flannel & kube-proxy fail with nftables errors. I'm stuck mid-upgrade on my nodes between Bookworm & Trixie now, because if I migrate the remaining nodes Concourse will be entirely unable to operate.

  17. rfpludwick commented on Aug 5, 2026

    @rfpludwick

    I used @Tyraeis' Dockerfile hack to success (I believe). Made my own to extend it:

    FROM concourse/concourse:8.2.4
    
    USER root
    
    RUN apk del \
    	iptables \
    	ip6tables ;
    
    RUN apk add --no-cache \
    	iptables-nft \
    	iptables-wrappers ;
    

    Pushed it to https://hub.docker.com/repository/docker/rfpludwick/concourse-nftables-temp/tags/8.2.4/ to use. So far so good.

  18. mubashir1osmani commented on Oct 3, 2026

    @mubashir1osmani
    Contributor

    i'd like to take this up, firewall CNI plugin hasnt been under development and the last commit was 6 months ago so im not willing to take that route. i can probably find a workaround and migrate to nft, making iptables a legacy fallback

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

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions