Sunucu İzleme Araçları: Grafana, Prometheus ve Netdata
Prometheus + Grafana stack kurulumu, Netdata, node_exporter, alert kuralları, dashboard oluşturma ve sunucu metrik izleme.
CrowdSec kurulumu, bouncer yapılandırması, saldırı algılama, IP engelleme, dashboard, koleksiyon ve senaryo yönetimi.
CrowdSec, topluluk destekli açık kaynaklı bir güvenlik motorudur. Log analizi yaparak saldırıları tespit eder ve topluluk tarafından paylaşılan tehdit istihbaratı ile proaktif koruma sağlar. Fail2ban'ın modern ve ölçeklenebilir alternatifi olarak düşünülebilir.
CrowdSec'in temel özellikleri:
# CrowdSec repository ekle
curl -s https://install.crowdsec.net | sudo sh
# CrowdSec kurulumu
sudo apt install crowdsec -y
# Firewall bouncer kurulumu
sudo apt install crowdsec-firewall-bouncer-iptables -y
# Servis durumu
sudo systemctl status crowdsec
sudo systemctl status crowdsec-firewall-bouncer
# docker-compose.yml
version: '3.8'
services:
crowdsec:
image: crowdsecurity/crowdsec:latest
container_name: crowdsec
restart: unless-stopped
ports:
- "8080:8080" # API
- "6060:6060" # Prometheus metrics
volumes:
- crowdsec_config:/etc/crowdsec
- crowdsec_data:/var/lib/crowdsec/data
- /var/log:/var/log:ro
- /var/log/nginx:/var/log/nginx:ro
environment:
- COLLECTIONS=crowdsecurity/linux crowdsecurity/nginx crowdsecurity/sshd
- GID=${GID-1000}
volumes:
crowdsec_config:
crowdsec_data:
docker compose up -d
Koleksiyonlar, belirli bir servis için parser, senaryo ve postoverflow kurallarını içeren paketlerdir:
# Mevcut koleksiyonları listele
sudo cscli collections list
# Koleksiyon kur
sudo cscli collections install crowdsecurity/linux
sudo cscli collections install crowdsecurity/nginx
sudo cscli collections install crowdsecurity/sshd
sudo cscli collections install crowdsecurity/apache2
sudo cscli collections install crowdsecurity/wordpress
sudo cscli collections install crowdsecurity/http-cve
# Koleksiyon güncelle
sudo cscli collections upgrade crowdsecurity/linux
# Tüm hub öğelerini güncelle
sudo cscli hub update
sudo cscli hub upgrade
Senaryolar, belirli saldırı kalıplarını tanımlayan YAML dosyalarıdır:
# Senaryoları listele
sudo cscli scenarios list
# Senaryo kur
sudo cscli scenarios install crowdsecurity/ssh-bf
sudo cscli scenarios install crowdsecurity/http-crawl-non_statics
sudo cscli scenarios install crowdsecurity/http-bad-user-agent
sudo cscli scenarios install crowdsecurity/http-probing
# Senaryo detayı
sudo cscli scenarios inspect crowdsecurity/ssh-bf
# Parser listele
sudo cscli parsers list
# Parser kur
sudo cscli parsers install crowdsecurity/sshd-logs
sudo cscli parsers install crowdsecurity/nginx-logs
# Firewall bouncer kur
sudo apt install crowdsec-firewall-bouncer-iptables -y
# Yapılandırma dosyası
sudo nano /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
# /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
mode: iptables
pid_dir: /var/run/
update_frequency: 10s
daemonize: true
log_mode: file
log_dir: /var/log/
log_level: info
log_compression: true
log_max_size: 100
log_max_backups: 3
log_max_age: 30
api_url: http://localhost:8080/
api_key: YOUR_API_KEY
disable_ipv6: false
deny_action: DROP
deny_log: true
deny_log_prefix: "crowdsec: "
blacklists_ipv4: crowdsec-blacklists
blacklists_ipv6: crowdsec6-blacklists
# Nginx bouncer kur
sudo apt install crowdsec-nginx-bouncer -y
# API key oluştur
sudo cscli bouncers add nginx-bouncer
# Yapılandırma
sudo nano /etc/crowdsec/bouncers/crowdsec-nginx-bouncer.conf
API_URL=http://localhost:8080/
API_KEY=YOUR_BOUNCER_API_KEY
CACHE_EXPIRATION=1
UPDATE_FREQUENCY=10
BAN_TEMPLATE_PATH=/var/lib/crowdsec/lua/templates/ban.html
CAPTCHA_TEMPLATE_PATH=/var/lib/crowdsec/lua/templates/captcha.html
# docker-compose.yml'e ekle
services:
bouncer-firewall:
image: crowdsecurity/crowdsec-firewall-bouncer-nftables:latest
container_name: crowdsec-firewall-bouncer
restart: unless-stopped
network_mode: host
cap_add:
- NET_ADMIN
- NET_RAW
volumes:
- ./crowdsec-firewall-bouncer.yaml:/etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
depends_on:
- crowdsec
# Aktif kararları listele
sudo cscli decisions list
# Manuel IP engelle
sudo cscli decisions add --ip 1.2.3.4 --reason "Manuel engelleme" --type ban --duration 24h
# IP aralığı engelle
sudo cscli decisions add --range 1.2.3.0/24 --reason "Subnet engelleme" --type ban
# Karar kaldır
sudo cscli decisions delete --ip 1.2.3.4
# Tüm kararları temizle
sudo cscli decisions delete --all
# Alertleri listele
sudo cscli alerts list
# Alert detayı
sudo cscli alerts inspect ALERT_ID
# Alertleri temizle
sudo cscli alerts delete --all
CrowdSec Console, web tabanlı yönetim panelidir:
# Console'a kayıt ol
sudo cscli console enroll YOUR_ENROLLMENT_KEY
# Kayıt sonrası servisi yeniden başlat
sudo systemctl restart crowdsec
Dashboard'a erişim: https://app.crowdsec.net
Dashboard özellikleri:
# /etc/crowdsec/scenarios/custom-brute-force.yaml
type: leaky
name: custom/brute-force
description: "Özel brute force algılama"
filter: "evt.Meta.log_type == 'ssh_failed-auth'"
groupby: evt.Meta.source_ip
capacity: 5
leakspeed: 10m
blackholeduration: 4h
labels:
service: ssh
type: brute_force
remediation: true
# Yapılandırmayı yeniden yükle
sudo systemctl reload crowdsec
# /etc/crowdsec/parsers/s02-enrich/whitelist.yaml
name: custom/whitelist
description: "Güvenilir IP'ler"
whitelist:
reason: "Güvenilir IP adresleri"
ip:
- "192.168.1.0/24"
- "10.0.0.0/8"
- "1.2.3.4"
expression:
- evt.Meta.source_ip startsWith '172.16.'
CrowdSec Prometheus metrikleri sunar:
# Metrikleri görüntüle
sudo cscli metrics
# Prometheus endpoint
curl http://localhost:6060/metrics
Grafana dashboard'u için: Dashboard ID 15620
# CrowdSec güncelle
sudo apt update
sudo apt upgrade crowdsec crowdsec-firewall-bouncer-iptables
# Hub güncelle
sudo cscli hub update
sudo cscli hub upgrade
# Docker güncelleme
docker compose pull
docker compose up -d
# CrowdSec logları
sudo tail -f /var/log/crowdsec.log
# Bouncer logları
sudo tail -f /var/log/crowdsec-firewall-bouncer.log
# Debug modu
sudo cscli config show
sudo cscli explain --file /var/log/auth.log --type syslog
REXE sunucularınızda CrowdSec kurarak topluluk destekli güvenlik koruması sağlayabilirsiniz. Fail2ban'dan farklı olarak CrowdSec, küresel tehdit istihbaratı paylaşımı sayesinde henüz sunucunuza saldırmamış IP'leri bile proaktif olarak engelleyebilir.
CrowdSec topluluk destekli tehdit istihbaratı paylaşır, yani diğer kullanıcıların tespit ettiği saldırgan IP'ler otomatik olarak sizin sunucunuzda da engellenir. Fail2ban sadece yerel log analizi yapar. CrowdSec daha modern, API tabanlı ve ölçeklenebilir bir mimariye sahiptir. Bouncer sistemi sayesinde farklı katmanlarda (firewall, Nginx, Cloudflare) engelleme yapabilir.
Bouncer'ın kurulu ve çalışır durumda olduğunu kontrol edin: 'sudo cscli bouncers list'. Firewall bouncer için API key'in doğru yapılandırıldığını doğrulayın. Log dosyalarının CrowdSec tarafından okunabildiğini kontrol edin. 'sudo cscli metrics' ile metrikleri inceleyin. Koleksiyonların doğru kurulduğunu doğrulayın: 'sudo cscli collections list'.
IP'yi engelleme listesinden kaldırın: 'sudo cscli decisions delete --ip SIZIN_IP'. Kalıcı çözüm için whitelist'e ekleyin: /etc/crowdsec/parsers/s02-enrich/whitelist.yaml dosyasına IP'nizi ekleyin ve 'sudo systemctl reload crowdsec' ile yeniden yükleyin.
https://app.crowdsec.net adresinden ücretsiz hesap oluşturun. Enrollment key alın. Sunucuda 'sudo cscli console enroll YOUR_KEY' komutunu çalıştırın. Console'da sunucuyu onaylayın. Servisi yeniden başlatın: 'sudo systemctl restart crowdsec'.
Docker container loglarını CrowdSec'e volume olarak bağlayın. docker-compose.yml'de '/var/log/nginx:/var/log/nginx:ro' gibi volume tanımları ekleyin. İlgili koleksiyonu kurun (örn: crowdsecurity/nginx). acquis.yaml dosyasında log kaynağını tanımlayın.
Whitelist yapılandırmasını güncelleyin. Senaryo parametrelerini ayarlayın (capacity ve leakspeed değerlerini artırın). 'sudo cscli alerts list' ile alertleri inceleyin ve yanlış pozitifleri belirleyin. Özel senaryo oluşturarak daha spesifik kurallar tanımlayın. Postoverflow kuralları ile yanlış pozitifleri filtreleyin.
Prometheus + Grafana stack kurulumu, Netdata, node_exporter, alert kuralları, dashboard oluşturma ve sunucu metrik izleme.
Squid forward proxy, HAProxy load balancer, SSL termination, ACL kuralları, caching, health check ve yüksek erişilebilirlik.
Nginx Proxy Manager Docker kurulumu, SSL sertifikası otomatik yenileme, proxy host ekleme, access list, redirect, stream ve custom location.