My fail2ban bans but rules of iptables do not block traffic !
root@LPM:~# fail2ban-client status
Status
|- Number of jail: 4
`- Jail list: ddos, dropbear, nextcloud, portscan
root@LPM:~# fail2ban-client status nextcloud
Status for the jail: nextcloud
|- Filter
| |- Currently failed: 1
| |- Total failed: 9
| `- File list: /var/log/messages
`- Actions
|- Currently banned: 2
|- Total banned: 2
`- Banned IP list: 37.170.77.195 37.164.202.152
root@LPM:~#
iptables-save looks OK.
When you show the result of iptables -L, add option -v and so the input/output interfaces will be listed too.
If the nextcloud service is hosted on external storage on the OpenWrt device, everytnig should work.
If it is hosted by device no the LAN, INPUT is not the right chain.
[quote="pavelgl, post:8, topic:90057"]
When you show the result of iptables -L, add option -v and so the input/output interfaces will be listed too.[/quote]
root@LPM:~# iptables -L -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
104K 68M f2b-nextcloud tcp -- any any anywhere anywhere
110K 69M f2b-nextcloud tcp -- any any anywhere anywhere
111K 69M f2b-nextcloud tcp -- any any anywhere anywhere
4311 332K ACCEPT all -- lo any anywhere anywhere /* !fw3 */
113K 70M input_rule all -- any any anywhere anywhere /* !fw3: Custom input rule chain */
107K 69M ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
0 0 DROP all -- any any anywhere anywhere ctstate INVALID /* !fw3 */
1475 85352 syn_flood tcp -- any any anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN /* !fw3 */
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:52900 /* !fw3: Allow-Wireguard-Inbound */
4512 572K zone_lan_input all -- br-lan any anywhere anywhere /* !fw3 */
811 94713 zone_wan_input all -- wan any anywhere anywhere /* !fw3 */
0 0 zone_WG_NDDC_input all -- WG_NDDC any anywhere anywhere /* !fw3 */
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
6606 841K forwarding_rule all -- any any anywhere anywhere /* !fw3: Custom forwarding rule chain */
5862 795K FLOWOFFLOAD all -- any any anywhere anywhere /* !fw3: Traffic offloading */ ctstate RELATED,ESTABLISHED FLOWOFFLOAD hw
5862 795K ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
19 988 DROP all -- any any anywhere anywhere ctstate INVALID /* !fw3 */
717 43983 zone_lan_forward all -- br-lan any anywhere anywhere /* !fw3 */
8 412 zone_wan_forward all -- wan any anywhere anywhere /* !fw3 */
0 0 zone_WG_NDDC_forward all -- WG_NDDC any anywhere anywhere /* !fw3 */
0 0 reject all -- any any anywhere anywhere /* !fw3 */
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
4311 332K ACCEPT all -- any lo anywhere anywhere /* !fw3 */
96432 73M output_rule all -- any any anywhere anywhere /* !fw3: Custom output rule chain */
86506 73M ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
0 0 DROP all -- any any anywhere anywhere ctstate INVALID /* !fw3 */
0 0 zone_lan_output all -- any br-lan anywhere anywhere /* !fw3 */
9926 647K zone_wan_output all -- any wan anywhere anywhere /* !fw3 */
0 0 zone_WG_NDDC_output all -- any WG_NDDC anywhere anywhere /* !fw3 */
Chain f2b-nextcloud (3 references)
pkts bytes target prot opt in out source destination
0 0 REJECT all -- any any 37-166-71-129.coucou-networks.fr anywhere reject-with icmp-port-unreachable
0 0 REJECT all -- any any 37.164.251.56 anywhere reject-with icmp-port-unreachable
0 0 REJECT all -- any any 37.164.202.152 anywhere reject-with icmp-port-unreachable
311K 205M RETURN all -- any any anywhere anywhere
Chain forwarding_WG_NDDC_rule (1 references)
pkts bytes target prot opt in out source destination
Chain forwarding_lan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain forwarding_rule (1 references)
pkts bytes target prot opt in out source destination
Chain forwarding_wan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain input_WG_NDDC_rule (1 references)
pkts bytes target prot opt in out source destination
Chain input_lan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain input_rule (1 references)
pkts bytes target prot opt in out source destination
Chain input_wan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain output_WG_NDDC_rule (1 references)
pkts bytes target prot opt in out source destination
Chain output_lan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain output_rule (1 references)
pkts bytes target prot opt in out source destination
Chain output_wan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain reject (3 references)
pkts bytes target prot opt in out source destination
401 24514 REJECT tcp -- any any anywhere anywhere /* !fw3 */ reject-with tcp-reset
385 68135 REJECT all -- any any anywhere anywhere /* !fw3 */ reject-with icmp-port-unreachable
Chain syn_flood (1 references)
pkts bytes target prot opt in out source destination
1475 85352 RETURN tcp -- any any anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN limit: avg 25/sec burst 50 /* !fw3 */
0 0 DROP all -- any any anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_dest_ACCEPT (3 references)
pkts bytes target prot opt in out source destination
0 0 DROP all -- any WG_NDDC anywhere anywhere ctstate INVALID /* !fw3: Prevent NAT leakage */
0 0 ACCEPT all -- any WG_NDDC anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_forward (1 references)
pkts bytes target prot opt in out source destination
0 0 forwarding_WG_NDDC_rule all -- any any anywhere anywhere /* !fw3: Custom WG_NDDC forwarding rule chain */
0 0 zone_wan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3: Zone WG_NDDC to wan forwarding policy */
0 0 zone_lan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3: Zone WG_NDDC to lan forwarding policy */
0 0 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
0 0 zone_WG_NDDC_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_input (1 references)
pkts bytes target prot opt in out source destination
0 0 input_WG_NDDC_rule all -- any any anywhere anywhere /* !fw3: Custom WG_NDDC input rule chain */
0 0 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
0 0 zone_WG_NDDC_src_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_output (1 references)
pkts bytes target prot opt in out source destination
0 0 output_WG_NDDC_rule all -- any any anywhere anywhere /* !fw3: Custom WG_NDDC output rule chain */
0 0 zone_WG_NDDC_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_src_ACCEPT (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- WG_NDDC any anywhere anywhere /* !fw3 */
Chain zone_lan_dest_ACCEPT (5 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- any br-lan anywhere anywhere /* !fw3 */
Chain zone_lan_forward (1 references)
pkts bytes target prot opt in out source destination
717 43983 forwarding_lan_rule all -- any any anywhere anywhere /* !fw3: Custom lan forwarding rule chain */
717 43983 zone_wan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3: Zone lan to wan forwarding policy */
56 3364 zone_WG_NDDC_dest_ACCEPT all -- any any anywhere anywhere /* !fw3: Zone lan to WG_NDDC forwarding policy */
56 3364 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
0 0 zone_lan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_lan_input (1 references)
pkts bytes target prot opt in out source destination
4512 572K input_lan_rule all -- any any anywhere anywhere /* !fw3: Custom lan input rule chain */
0 0 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
4512 572K zone_lan_src_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_lan_output (1 references)
pkts bytes target prot opt in out source destination
0 0 output_lan_rule all -- any any anywhere anywhere /* !fw3: Custom lan output rule chain */
0 0 zone_lan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_lan_src_ACCEPT (1 references)
pkts bytes target prot opt in out source destination
4512 572K ACCEPT all -- br-lan any anywhere anywhere /* !fw3 */
Chain zone_wan_dest_ACCEPT (3 references)
pkts bytes target prot opt in out source destination
0 0 DROP all -- any wan anywhere anywhere ctstate INVALID /* !fw3: Prevent NAT leakage */
10587 688K ACCEPT all -- any wan anywhere anywhere /* !fw3 */
Chain zone_wan_dest_REJECT (1 references)
pkts bytes target prot opt in out source destination
0 0 reject all -- any wan anywhere anywhere /* !fw3 */
Chain zone_wan_forward (1 references)
pkts bytes target prot opt in out source destination
8 412 forwarding_wan_rule all -- any any anywhere anywhere /* !fw3: Custom wan forwarding rule chain */
0 0 zone_lan_dest_ACCEPT esp -- any any anywhere anywhere /* !fw3: Allow-IPSec-ESP */
0 0 zone_lan_dest_ACCEPT udp -- any any anywhere anywhere udp dpt:isakmp /* !fw3: Allow-ISAKMP */
8 412 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
0 0 zone_wan_dest_REJECT all -- any any anywhere anywhere /* !fw3 */
Chain zone_wan_input (1 references)
pkts bytes target prot opt in out source destination
811 94713 input_wan_rule all -- any any anywhere anywhere /* !fw3: Custom wan input rule chain */
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:bootpc /* !fw3: Allow-DHCP-Renew */
25 2064 ACCEPT icmp -- any any anywhere anywhere icmp echo-request /* !fw3: Allow-Ping */
0 0 ACCEPT igmp -- any any anywhere anywhere /* !fw3: Allow-IGMP */
0 0 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
786 92649 zone_wan_src_REJECT all -- any any anywhere anywhere /* !fw3 */
Chain zone_wan_output (1 references)
pkts bytes target prot opt in out source destination
9926 647K output_wan_rule all -- any any anywhere anywhere /* !fw3: Custom wan output rule chain */
9926 647K zone_wan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_wan_src_REJECT (1 references)
pkts bytes target prot opt in out source destination
786 92649 reject all -- wan any anywhere anywhere /* !fw3 */
and now it is working fine !
root@LPM:~# iptables -L -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
379 28709 ACCEPT all -- lo any anywhere anywhere /* !fw3 */
4371 676K input_rule all -- any any anywhere anywhere /* !fw3: Custom input rule chain */
3798 549K ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
82 4264 DROP all -- any any anywhere anywhere ctstate INVALID /* !fw3 */
243 14128 syn_flood tcp -- any any anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN /* !fw3 */
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:52900 /* !fw3: Allow-Wireguard-Inbound */
418 114K zone_lan_input all -- br-lan any anywhere anywhere /* !fw3 */
73 9505 zone_wan_input all -- wan any anywhere anywhere /* !fw3 */
0 0 zone_WG_NDDC_input all -- WG_NDDC any anywhere anywhere /* !fw3 */
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
90 6480 f2b-nextcloud tcp -- any any anywhere anywhere
271 20663 forwarding_rule all -- any any anywhere anywhere /* !fw3: Custom forwarding rule chain */
220 17254 FLOWOFFLOAD all -- any any anywhere anywhere /* !fw3: Traffic offloading */ ctstate RELATED,ESTABLISHED FLOWOFFLOAD hw
220 17254 ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
0 0 DROP all -- any any anywhere anywhere ctstate INVALID /* !fw3 */
48 3233 zone_lan_forward all -- br-lan any anywhere anywhere /* !fw3 */
3 176 zone_wan_forward all -- wan any anywhere anywhere /* !fw3 */
0 0 zone_WG_NDDC_forward all -- WG_NDDC any anywhere anywhere /* !fw3 */
0 0 reject all -- any any anywhere anywhere /* !fw3 */
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
379 28709 ACCEPT all -- any lo anywhere anywhere /* !fw3 */
3821 972K output_rule all -- any any anywhere anywhere /* !fw3: Custom output rule chain */
3197 928K ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
92 4784 DROP all -- any any anywhere anywhere ctstate INVALID /* !fw3 */
19 2716 zone_lan_output all -- any br-lan anywhere anywhere /* !fw3 */
513 36113 zone_wan_output all -- any wan anywhere anywhere /* !fw3 */
0 0 zone_WG_NDDC_output all -- any WG_NDDC anywhere anywhere /* !fw3 */
Chain f2b-nextcloud (1 references)
pkts bytes target prot opt in out source destination
0 0 REJECT all -- any any 37-166-71-129.coucou-networks.fr anywhere reject-with icmp-port-unreachable
3 192 REJECT all -- any any 37.166.123.73 anywhere reject-with icmp-port-unreachable
0 0 REJECT all -- any any 37.164.251.56 anywhere reject-with icmp-port-unreachable
0 0 REJECT all -- any any 37.164.202.152 anywhere reject-with icmp-port-unreachable
87 6288 RETURN all -- any any anywhere anywhere
Chain forwarding_WG_NDDC_rule (1 references)
pkts bytes target prot opt in out source destination
Chain forwarding_lan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain forwarding_rule (1 references)
pkts bytes target prot opt in out source destination
Chain forwarding_wan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain input_WG_NDDC_rule (1 references)
pkts bytes target prot opt in out source destination
Chain input_lan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain input_rule (1 references)
pkts bytes target prot opt in out source destination
Chain input_wan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain output_WG_NDDC_rule (1 references)
pkts bytes target prot opt in out source destination
Chain output_lan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain output_rule (1 references)
pkts bytes target prot opt in out source destination
Chain output_wan_rule (1 references)
pkts bytes target prot opt in out source destination
Chain reject (3 references)
pkts bytes target prot opt in out source destination
40 3973 REJECT tcp -- any any anywhere anywhere /* !fw3 */ reject-with tcp-reset
30 5280 REJECT all -- any any anywhere anywhere /* !fw3 */ reject-with icmp-port-unreachable
Chain syn_flood (1 references)
pkts bytes target prot opt in out source destination
243 14128 RETURN tcp -- any any anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN limit: avg 25/sec burst 50 /* !fw3 */
0 0 DROP all -- any any anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_dest_ACCEPT (3 references)
pkts bytes target prot opt in out source destination
0 0 DROP all -- any WG_NDDC anywhere anywhere ctstate INVALID /* !fw3: Prevent NAT leakage */
0 0 ACCEPT all -- any WG_NDDC anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_forward (1 references)
pkts bytes target prot opt in out source destination
0 0 forwarding_WG_NDDC_rule all -- any any anywhere anywhere /* !fw3: Custom WG_NDDC forwarding rule chain */
0 0 zone_wan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3: Zone WG_NDDC to wan forwarding policy */
0 0 zone_lan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3: Zone WG_NDDC to lan forwarding policy */
0 0 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
0 0 zone_WG_NDDC_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_input (1 references)
pkts bytes target prot opt in out source destination
0 0 input_WG_NDDC_rule all -- any any anywhere anywhere /* !fw3: Custom WG_NDDC input rule chain */
0 0 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
0 0 zone_WG_NDDC_src_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_output (1 references)
pkts bytes target prot opt in out source destination
0 0 output_WG_NDDC_rule all -- any any anywhere anywhere /* !fw3: Custom WG_NDDC output rule chain */
0 0 zone_WG_NDDC_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_WG_NDDC_src_ACCEPT (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- WG_NDDC any anywhere anywhere /* !fw3 */
Chain zone_lan_dest_ACCEPT (5 references)
pkts bytes target prot opt in out source destination
19 2716 ACCEPT all -- any br-lan anywhere anywhere /* !fw3 */
Chain zone_lan_forward (1 references)
pkts bytes target prot opt in out source destination
48 3233 forwarding_lan_rule all -- any any anywhere anywhere /* !fw3: Custom lan forwarding rule chain */
48 3233 zone_wan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3: Zone lan to wan forwarding policy */
0 0 zone_WG_NDDC_dest_ACCEPT all -- any any anywhere anywhere /* !fw3: Zone lan to WG_NDDC forwarding policy */
0 0 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
0 0 zone_lan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_lan_input (1 references)
pkts bytes target prot opt in out source destination
418 114K input_lan_rule all -- any any anywhere anywhere /* !fw3: Custom lan input rule chain */
0 0 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
418 114K zone_lan_src_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_lan_output (1 references)
pkts bytes target prot opt in out source destination
19 2716 output_lan_rule all -- any any anywhere anywhere /* !fw3: Custom lan output rule chain */
19 2716 zone_lan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_lan_src_ACCEPT (1 references)
pkts bytes target prot opt in out source destination
418 114K ACCEPT all -- br-lan any anywhere anywhere /* !fw3 */
Chain zone_wan_dest_ACCEPT (3 references)
pkts bytes target prot opt in out source destination
0 0 DROP all -- any wan anywhere anywhere ctstate INVALID /* !fw3: Prevent NAT leakage */
561 39346 ACCEPT all -- any wan anywhere anywhere /* !fw3 */
Chain zone_wan_dest_REJECT (1 references)
pkts bytes target prot opt in out source destination
0 0 reject all -- any wan anywhere anywhere /* !fw3 */
Chain zone_wan_forward (1 references)
pkts bytes target prot opt in out source destination
3 176 forwarding_wan_rule all -- any any anywhere anywhere /* !fw3: Custom wan forwarding rule chain */
0 0 zone_lan_dest_ACCEPT esp -- any any anywhere anywhere /* !fw3: Allow-IPSec-ESP */
0 0 zone_lan_dest_ACCEPT udp -- any any anywhere anywhere udp dpt:isakmp /* !fw3: Allow-ISAKMP */
3 176 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
0 0 zone_wan_dest_REJECT all -- any any anywhere anywhere /* !fw3 */
Chain zone_wan_input (1 references)
pkts bytes target prot opt in out source destination
73 9505 input_wan_rule all -- any any anywhere anywhere /* !fw3: Custom wan input rule chain */
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:bootpc /* !fw3: Allow-DHCP-Renew */
3 252 ACCEPT icmp -- any any anywhere anywhere icmp echo-request /* !fw3: Allow-Ping */
0 0 ACCEPT igmp -- any any anywhere anywhere /* !fw3: Allow-IGMP */
0 0 ACCEPT all -- any any anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
70 9253 zone_wan_src_REJECT all -- any any anywhere anywhere /* !fw3 */
Chain zone_wan_output (1 references)
pkts bytes target prot opt in out source destination
513 36113 output_wan_rule all -- any any anywhere anywhere /* !fw3: Custom wan output rule chain */
513 36113 zone_wan_dest_ACCEPT all -- any any anywhere anywhere /* !fw3 */
Chain zone_wan_src_REJECT (1 references)
pkts bytes target prot opt in out source destination
70 9253 reject all -- wan any anywhere anywhere /* !fw3 */
You are welcome.
Keep in mind, that you should finetune the fail2ban configuration.
You have listed several services, some of which are running on the device itself (like dropbear).
So you should create several jails with INPUT and FORWARD chains included.
thanks @pavelgl
I also note that I need to restart service firewall before service fail2ban.
If not, I get multiples f2b rules in iptables and ban not work no more.
the iptables entries f2b creates aren't persistent, if you restart your fw they'll be lost.
if you don't restart f2b at the same time, f2b will believe IPs are blocket, while the entries
are gone from iptables.