ซ่อมคอมพิวเตอร์นอกสถานที่ รามตำแหง บางกะปิ 083-792-5426

วันเสาร์ที่ 27 ตุลาคม พ.ศ. 2555

ติดตั้ง Fail2ban บน Ubuntu Server 10.04 LTS


Fail2ban เป็นโปรแกรมตรวจสอบ log files และแบน IP ที่ล็อกอินผิดหลายๆครั้ง โดยสนับสนุน Service หลายตัวเช่น apache, vsftpd, proftpd, postfix, couriersmtp, named (DNS),ssl เป็นต้น
มีหลักการทำงานดังนี้ โปรแกรม Fail2ban จะตรวจสอบ Log Files เป็นระยะ ว่ามี IP ที่ล๊อคอินเข้าระบบแล้ว Fail ติดๆกัน ครบตามจำนวนที่ตั้งไว้ในไฟล์คอนฟิก จะแบน IPหมายเลขนั้นโดยไปกำหนดที่ iptable ให้ Block IP Address   เมื่อแบน IP ครบตามกำหนดเวลาที่ตั้งไว้ในไฟล์คอนฟิก Fail2ban จะไปแก้ไข iptable  ให้ IP Address นั้นสามารถใช้งานได้ตามเดิม
ใช้คำสั่ง
Apt-get install fail2ban

ต่อไปทำการแก้ไขโดยใช้คำสั่ง
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
nano /etc/fail2ban/jail.local

ต่อไปทำการแก้ไขข้อความภายใน
[ssh-ddos]
Enabled = true
Port = ssh
Filter = sshd-ddos
Logpath = /var/log/auth.log
Maxrety = 3
ได้ทำการแก้ไขให้กับ apache, vsftpd, proftpd, postfix เป็นต้น


ทำการบันทึกแล้วออกจากการแก้ไข

จากนั้นทำการ restart fail2ban
ตรวจสอบการทำงานของ fail2ban
tail /var/log/fail2ban.log

ตรวจสอบ IP ที่ถูกแบน
iptables  -n  -L
จากนั้นระบุ IP ที่ต้องการยกเลิกแบนไอพี โดยใช้คำสั่ง
iptables -D fail2ban-ssh -s “ใส่หมายเลข IP ที่ถูกแบน -j DROP

0 ความคิดเห็น:

แสดงความคิดเห็น

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design Downloaded from Free Blogger Templates Download | free website templates downloads | Vector Graphics | Web Design Resources Download.