iptables

Administration tool for IPv4/IPv6 packet filtering and NAT

Block IP address

   1 cat /var/log/auth.log | grep Failed
   2 iptables -A INPUT -s 14.39.42.133 -j DROP
   3 iptables -A INPUT -s 80.94.95.181 -j DROP
   4 iptables -A INPUT -s 77.90.185.59  -j DROP
   5 iptables -L
   6 apt install whois
   7 whois 14.39.42.133 

firewall.sh

   1 iptables -F
   2 sh mail_failure_ip_list.sh | xargs -i iptables -A INPUT -s {} -j DROP
   3 iptables -L

mail_failure_ip_list.sh

   1 #!/bin/sh
   2 cat /var/log/mail.log | grep failure | awk '//{print $5}' | sort | uniq | sed 's/unknown//g' | sed 's/://g' | sed 's/\[//g' | sed 's/\]//g'

iptables (last edited 2023-10-08 15:40:12 by vitor)