/errors/iptables/no-chain-target-match-by-that-name
iptables: No chain/target/match by that name.
- tool
- iptables / nftables
- exit code
- 1
- versions
- iptables 1.8 (nf_tables and legacy backends)
- os
- linux
iptables: No chain/target/match by that name. means a name in your command does not exist in the kernel: a chain (in the table you are using), a target after -j, or a match module after -m. Most often a rule jumps to a user-defined chain that has not been created yet, or a NAT target is used without -t nat. List the chains with iptables -t TABLE -L -n, create missing chains with iptables -N, and check that the needed kernel modules are available.
Typical triggers
iptables -A INPUT -j MYCHAIN # MYCHAIN not created yet
iptables -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.0.0.2 # PREROUTING exists only in nat/mangle/raw
iptables -A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT # module missing in the kernelFixed versions:
iptables -N MYCHAIN
iptables -A INPUT -j MYCHAIN
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.0.0.2
modprobe xt_conntrackVariants of the message
The legacy backend prints the short form above. The nf_tables backend (default on current distributions) gives more specific messages for some cases: iptables v1.8.7 (nf_tables): Chain 'MYCHAIN' does not exist when you append to or list a chain that is missing, and Couldn't load target `NAME':No such file or directory when iptables finds neither a chain nor a target extension with that name after -j. For deleting a rule that is not there, both backends print iptables: Bad rule (does a matching rule exist in that chain?).
Docker
iptables: No chain/target/match by that name together with Error response from daemon: driver failed programming external connectivity means Docker's DOCKER chains in the nat and filter tables were removed, usually because firewalld or an iptables restore flushed the rules after Docker started. Restart Docker (systemctl restart docker) so it recreates them, and make the firewall service start before Docker.
Find what is missing
iptables -t filter -L -n | grep '^Chain'
iptables -t nat -L -n | grep '^Chain'
lsmod | grep -E '^(xt_|nf_|ip_tables)'