Warden
Block abusive IPs on Docker-published ports with nftables
Use Warden to block inbound connections to Docker-published ports and verify that other clients and container-initiated connections still work.
Check the packet path
When rootful Docker publishes a port on a bridge network using destination NAT, the host forwards incoming traffic to the container. A rule limited to the host's INPUT hook misses that forwarded path. Warden 0.1.49 and later applies inbound source bans to forwarded traffic as well as host services.
This walkthrough uses Warden's nft backend on the Linux host. Warden owns the inet witen table. Leave Docker's firewall configuration in place. Docker log discovery is optional for this test.
- Install Warden using the Warden installation guide and confirm the workload publishes a port. Run
docker psto check the port mapping. - Confirm the forwarded packets reach this host with the original client IP. When a CDN or load balancer connects from its own address, enforce the visitor ban at a layer that sees the visitor. See Client IPs behind a proxy.
- Keep a recovery console available. Use a separate, disposable test client that you control and whose address is absent from existing bans and trusted ranges. Use a second client with a different source IP to check normal access.
If the host is still in observation mode, follow the firewall setup steps to validate the configuration and enable backend = "nft".
Verify a temporary ban
On the Docker host, check the running version, Warden's forwarding chain, and existing bans.
warden --version
sudo nft list chain inet witen forward
sudo warden blocked --source all- From both clients, make a normal request to the published endpoint using its direct host address and port. For HTTP, run
curl --noproxy '*' --max-time 5 http://docker-host.example:8080/with your actual URL. Both requests should complete before the ban. - On the host, replace
TEST_IPwith the test client's source address. Add a two-minute ban. An address ban applies across the host and its forwarded services.
sudo warden ban TEST_IP 120
sudo warden blocked --source localWhile the ban is active, repeat the request from both clients. The banned client's new connection should fail and the other client's should succeed. A timeout is possible even with a reject verdict after destination NAT. Inspect the matching packet counter in sudo nft list table inet witen to confirm which firewall handled the traffic.
Where you have a controlled endpoint on the banned client, also verify that a container can open a connection to it and receive the reply. Warden exempts replies to connections initiated by a forwarded guest from its inbound source ban. Other firewall and outbound policies still apply.
Remove the temporary ban when you finish, then confirm the test client can reach the published port again.
sudo warden unban TEST_IP
sudo warden blocked --source localTroubleshoot the result
- If the forwarding chain is missing, verify Warden is running with the
nftbackend on the Docker host. Runsudo warden validate --config /etc/witen/warden.tomland check the service status. - If the ban is listed but the request succeeds, verify the actual source address and host. Host-network containers and userspace forwarding can take a different path. Clients on the same bridge can bypass routed forwarding unless the host sends bridged traffic through netfilter for that address family.
- If both clients lose access, remove the test ban and check whether both arrive through one NAT or proxy before repeating the test.