IPTABLES - block IPs that do not complete handshake/visit webpage

Solution 1:

since i write the entries to iptables myself and execute with iptables-restore < /etc/iptables/rules, and failt2ban uses iptables too, i dont know how would both work together.

You can:

  1. either use --noflush option with iptables-restore to avoid removal of fail2ban (and other rules), and filter f2b-* chains by iptables-save.
  2. or switch to nftables (since fail2ban support this action) and it can target the tables by dump and restore separately, so they would not remove or overwrite fail2ban chains.