I'm trying to configure firewalld (v0.4.4.2) on Debian 9 to REJECT invalid requests originating from an internal network.
However, if I set the default target of the zone in question to REJECT, the requests still appear to be dropped. (If I test it, I get connection times out instead of beeing rejected.)
According to the docs, REJECT is not statically assigned, but:
The %%REJECT%% target is used in block zone to reject (with default firewalld reject type) every packet not matching any rule.
So it seems that default reject type is the wrong one. I'm not sure how to change this. Thanks for any advice.
iptables -L (cropped):
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
INPUT_direct all -- anywhere anywhere
INPUT_ZONES_SOURCE all -- anywhere anywhere
INPUT_ZONES all -- anywhere anywhere
DROP all -- anywhere anywhere ctstate INVALID
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
[...]
Maybe firewalld is using the REJECT above, but it looks fine with icmp-host-prohibited. However I dont get that answer on a client.
iptables -vnL:
Chain IN_internal (1 references)
pkts bytes target prot opt in out source destination
0 0 IN_internal_log all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 IN_internal_deny all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 IN_internal_allow all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
iptablesrules are processed in order, and since you seem to have a DROP rule that matches all invalid packets before the REJECT rule, the processing may never reach the REJECT rule. However,iptables -Ldoes not always tell the whole story: it omits the fields that would indicate if a particular rule applies to specific interface(s) only. You should probably useiptables -Lvninstead, so that the full meaning of each rule can be reviewed.iptableslingo, it'siptables [...] -p tcp -j REJECT --reject-with tcp-reset; I don't remember thefirewalldequivalent right now), then another REJECT for everything else, using the default ICMP reject response.icmp-host-prohibitedinstead oftcp-reset). I'll update as soon as I've tested it.