ai

CrowdSec IPS Monitoring และ Alerting — วิธีใช้

CrowdSec IPS Monitoring และ Alerting — วิธีใช้

CrowdSec IPS

CrowdSec IPS Monitoring และ Alerting — วิธีใช้

CrowdSec เป็น Open-source IPS ใช้ Crowd Intelligence วิเคราะห์ Logs ตรวจจับ Attacks แชร์ IP อันตรายกับ Community คล้าย Fail2ban แต่มี Community Blocklist

Monitoring ด้วย Dashboard Alerting ผ่าน Slack Email Telegram Bouncers Block IP อัตโนมัติ iptables Nginx Cloudflare

Installation และ Configuration

=== CrowdSec Installation ===

1. Install CrowdSec (Debian/Ubuntu)

curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.deb.sh | sudo bash
sudo apt install crowdsec

2. Install Bouncer (Firewall)

sudo apt install crowdsec-firewall-bouncer-iptables

3. ตรวจสอบ Status

sudo systemctl status crowdsec
sudo cscli metrics
sudo cscli decisions list
sudo cscli alerts list

4. Configuration Files

/etc/crowdsec/config.yaml — Main config

/etc/crowdsec/acquis.yaml — Log sources

/etc/crowdsec/profiles.yaml — Decision profiles

/etc/crowdsec/scenarios/ — Detection scenarios

/etc/crowdsec/parsers/ — Log parsers

/etc/crowdsec/postoverflows/ — Post-processing

5. acquis.yaml — กำหนด Log Sources

filenames:

  • /var/log/nginx/access.log
  • /var/log/nginx/error.log

labels:

type: nginx

---

เนื้อหาเกี่ยวข้อง — ดูเพิ่มเติมเรื่อง QuestDB Time Series Micro-segmentation

filenames:

  • /var/log/auth.log

labels:

type: syslog

---

filenames:

  • /var/log/apache2/access.log

labels:

type: apache2

6. Install Collections (Detection Rules)

sudo cscli collections install crowdsecurity/nginx
sudo cscli collections install crowdsecurity/sshd
sudo cscli collections install crowdsecurity/linux
sudo cscli collections install crowdsecurity/http-cve
sudo cscli collections install crowdsecurity/wordpress

7. ดู Collections ที่ติดตั้ง

sudo cscli collections list
sudo cscli scenarios list
sudo cscli parsers list

8. ทดสอบ — Ban IP ด้วยมือ

sudo cscli decisions add --ip 192.168.1.100 --duration 1h --reason "manual test"
sudo cscli decisions list
sudo cscli decisions delete --ip 192.168.1.100

9. Enroll to CrowdSec Console (Dashboard)

sudo cscli console enroll YOUR_ENROLLMENT_KEY

แนะนำเพิ่มเติม — คู่มือเทรดจาก SiamCafeBook

ดู Dashboard ที่ https://app.crowdsec.net

echo "CrowdSec Installation Complete"

echo " Config: /etc/crowdsec/"

เนื้อหาเกี่ยวข้อง — อ่านต่อ: Generative AI คืออะไร — ทุกเรื่องที่ต้องรู้เกี่ยวกับ AI สร้างสรรค์ 2026

echo " Logs: /var/log/crowdsec.log"

echo " CLI: cscli"

echo " Dashboard: https://app.crowdsec.net"

Alerting Configuration

=== CrowdSec Alerting ===

1. Slack Notification

/etc/crowdsec/notifications/slack.yaml

type: slack

name: slack_default

log_level: info

format: |

🚨 *CrowdSec Alert*

*IP:* {{.Alert.Source.IP}}

แนะนำเพิ่มเติม — คอร์สเทรด Forex ที่ iCafeForex

*Scenario:* {{.Alert.Scenario}}

*Country:* {{.Alert.Source.Cn}}

*Events:* {{.Alert.EventsCount}}

*Decision:* {{range .Alert.Decisions}}{{.Type}} for {{.Duration}}{{end}}

webhook: https://hooks.slack.com/services/YOUR/WEBHOOK/URL

2. Telegram Notification

/etc/crowdsec/notifications/telegram.yaml

type: http

name: telegram_default

log_level: info

เนื้อหาเกี่ยวข้อง — บทความที่เกี่ยวข้อง: osi model devices — ข้อมูลครบถ้วน 2026

format: |

🚨 CrowdSec Alert

IP: {{.Alert.Source.IP}}

Scenario: {{.Alert.Scenario}}

Country: {{.Alert.Source.Cn}}

url: https://api.telegram.org/botYOUR_TOKEN/sendMessage

method: POST

headers:

CrowdSec IPS Monitoring และ Alerting — วิธีใช้

Content-Type: application/json

body: |

{"chat_id": "YOUR_CHAT_ID", "text": "{{.}}", "parse_mode": "Markdown"}

3. Email Notification

/etc/crowdsec/notifications/email.yaml

type: email

name: email_default

log_level: info

format: |

CrowdSec Alert: {{.Alert.Scenario}}

IP: {{.Alert.Source.IP}}

Country: {{.Alert.Source.Cn}}

smtp_host: smtp.gmail.com

smtp_port: 587

smtp_username: alerts@company.com

เนื้อหาเกี่ยวข้อง — แนะนำให้อ่าน Ceph Storage Cluster Monitoring และ Alerting

smtp_password: app-password

sender_email: alerts@company.com

receiver_emails:

  • security@company.com

4. profiles.yaml — กำหนดว่า Scenario ไหนแจ้งเตือน

name: default_ip_remediation

filters:

  • Alert.Remediation == true && Alert.GetScope() == "Ip"

decisions:

  • type: ban

duration: 4h

notifications:

  • slack_default
  • telegram_default

on_success: break

5. Severity-based Alerting

name: critical_alerts

filters:

  • Alert.Scenario contains "ssh" || Alert.Scenario contains "cve"

decisions:

  • type: ban

duration: 24h

notifications:

  • slack_default
  • email_default
  • telegram_default

on_success: break

6. Reload Configuration

sudo systemctl reload crowdsec

7. Test Notification

sudo cscli notifications test slack_default

echo "Alerting Configuration:"

echo " Slack: /etc/crowdsec/notifications/slack.yaml"

echo " Telegram: /etc/crowdsec/notifications/telegram.yaml"

echo " Email: /etc/crowdsec/notifications/email.yaml"

echo " Profiles: /etc/crowdsec/profiles.yaml"

Best Practices

  • Collections: ติดตั้ง Collections ที่เหมาะกับ Services เช่น nginx, sshd, wordpress
  • Bouncers: ใช้ Firewall Bouncer สำหรับ Block ระดับ Network
  • Console: Enroll กับ CrowdSec Console ดู Dashboard แบบ Real-time
  • Alerting: ตั้ง Alerts สำหรับ Critical Scenarios เช่น CVE, SSH Brute Force
  • Whitelist: ตั้ง Whitelist สำหรับ IP ที่เชื่อถือ ป้องกัน False Positive
  • Multi-server: ใช้ LAPI กระจาย Decisions ไปหลาย Servers

CrowdSec คืออะไร

Open-source IPS Crowd Intelligence วิเคราะห์ Logs ตรวจจับ Attacks แชร์ IP อันตราย Community คล้าย Fail2ban Community Blocklist หลาย Platforms

XM Legend · เทรดเดอร์ & ผู้สอน Forex 13 ปี

ผู้ก่อตั้ง SiamCafe ตั้งแต่ปี 1997 · เทรดเดอร์สาย Forex มากกว่า 13 ปี ได้รับการยกย่องเป็น XM Legend · แบ่งปันความรู้ Forex, ไอที, AI และการเทรด จากประสบการณ์จริงในตลาดจริง