Intrusion Detection con Snort
1. Installazione
apt install -y snort
# Configura la rete: 192.168.1.0/24
2. Configurazione base
nano /etc/snort/snort.conf
# Imposta la rete interna
var HOME_NET 192.168.1.0/24
var EXTERNAL_NET !$HOME_NET
3. Regole personalizzate
nano /etc/snort/rules/local.rules
# Alert su scan di porte
alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:"Port scan detected"; flags:S; threshold:type both, track by_src, count 20, seconds 60; sid:1000001; rev:1;)
# Alert su tentativi SSH
alert tcp $EXTERNAL_NET any -> $HOME_NET 22 (msg:"SSH connection attempt"; flags:S; sid:1000002; rev:1;)
# Alert su traffico DNS sospetto
alert udp any any -> any 53 (msg:"DNS query unusually long"; dsize:>512; sid:1000003; rev:1;)
4. Modalità
# Sniffer (solo visualizza)
snort -v -i eth0
# IDS (log alerts)
snort -A console -q -c /etc/snort/snort.conf -i eth0
# Come servizio
systemctl enable snort
systemctl start snort
5. Analisi alert
tail -f /var/log/snort/alert
cat /var/log/snort/alert | grep "Port scan"
Risultato: Sistema di rilevamento intrusioni attivo sulla rete interna.