Con UFW.
Bannare un IP
DROP silenzioso
ufw deny from 1.2.3.4
REJECT esplicito
ufw reject from 1.2.3.4
Bannare solo una porta
Esempio SMTP 25:
ufw deny from 1.2.3.4 to any port 25
HTTPS:
ufw deny from 1.2.3.4 to any port 443
Inserire il ban in cima alle regole
Molto utile.
ufw insert 1 deny from 1.2.3.4
oppure:
ufw insert 1 reject from 1.2.3.4
Vedere le regole numerate
ufw status numbered
Eliminare una regola per numero
ufw delete 24
Eliminare regola specifica
ufw delete deny from 1.2.3.4
Whitelist IP
ufw allow from 1.2.3.4
solo SSH:
ufw allow from 1.2.3.4 to any port 22
Verifica rapida IP bannato
ufw status | grep 1.2.3.4
Reload firewall
ufw reload
Logging
ufw logging on
oppure:
ufw logging medium
Stato completo
ufw status verbose
numero IP bloccati
ufw status numbered | wc -l
Visualizzare solo deny/reject
ufw status | grep -E 'DENY|REJECT'
Contare i ban
ufw status | grep -E 'DENY|REJECT' | wc -l
IMPORTANTISSIMO in produzione
Prima di fare prove:
screen
oppure:
tmux
Per evitare di chiuderti fuori SSH accidentalmente.