วิธีการแก้ไขปัญหานี้ ผมจะเลือกใช้งานตัว Fail2ban และ CSF เข้ามาช่วย โดยทำการติดตั้ง Fail2ban และ CSF ให้เรียบร้อย ตามที่ OS ของท่านใช้งานอยู่นะครับ สำหรับ CentOS สามารถใช้คำสั่งนี้ได้เลยครับ
yum install fail2ban systemctl enable fail2ban cd /usr/src/ wget https://download.configserver.com/csf.tgz tar -xzf csf.tgz cd csf sh install.sh
หลังจาก Service ต่างๆพร้อมแล้ว ให้ทำการแก้ไขไฟล์ csf.conf สำหรับ Fail2ban
nano /etc/fail2ban/action.d/csf.conf # Input in file csf.conf # Fail2Ban configuration file # http://configserver.com/cp/csf.html # # Note: CSF doesn't play nicely with other actions. It has been observed to # remove bans created by other iptables based actions. If you are going to use # this action, use it for all of your jails. # # DON'T MIX CSF and other IPTABLES based actions [Definition] actionstart = actionstop = actioncheck = actionban = csf --deny <ip> "banned by Fail2Ban <name>" actionunban = csf --denyrm <ip> [Init] # Name used in CSF configuration # name = default # DEV NOTES: # # based on apf.conf by Mark McKinstry
ทำการเพิ่ม Rule ของ DNS Query สำหรับโดเมน pizzaseo.com ที่มีการยิง DNS Query เข้ามา แล้วก็แบนมันซะ
nano /etc/fail2ban/filter.d/pihole-bad.conf # Add to file pi-hole-bad.conf [INCLUDES] before = common.conf [Definition] _daemon = dnsmasq failregex = .*query.*pizzaseo.com from <HOST> ignoreregex = nano /etc/fail2ban/jail.local # Append in file jail.local [pihole-bad] enabled = true port = 53 action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp] %(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp] logpath = /var/log/pihole.log findtime = 60 maxretry = 1 bantime = 86400 banaction = csf
เมื่อตั้งค่าเสร็จเรียบร้อย ก็ทำการ Restart Fail2ban และตรวจสอบสถานะการทำงานของระบบ
systemctl restart fail2ban systemctl status fail2ban fail2ban-client status pihole-bad
Status for the jail: pihole-bad |- Filter | |- Currently failed: 0 | |- Total failed: 1211 | `- File list: /var/log/pihole.log `- Actions |- Currently banned: 7 |- Total banned: 7 `- Banned IP list: 73.133.181.197 47.152.202.28 47.150.161.174 172.74.3.46 78.108.216.207 72.202.137.151 47.204.23.134
อัพเดต: หลังจากที่ได้นำเอา Fail2Ban เข้ามาช่วย Block DNS Flood Attack ผลปรากฏว่า ผ่านไปประมาณ 2 วัน ทำการ Block ไปมากกว่า 834 IP Address สุดยอดจริงๆ
Status for the jail: pihole-bad |- Filter | |- Currently failed: 0 | |- Total failed: 6714 | `- File list: /var/log/pihole.log `- Actions |- Currently banned: 297 |- Total banned: 834 `- Banned IP list: xxxThe post Pi-Hole Block pizzaseo.com DNS Flood Attack first appeared on 1412.]]>
Uninstall-WindowsFeature Windows-DefenderThe post Uninstall Windows Defender first appeared on 1412.]]>
จากนี้ไปจะเป็นเรื่องราวต่างๆที่ผมได้พบเจอบนเส้นทางเดิน เล่าประสบการณ์ต่างๆ หลักๆจะเกี่ยวกับระบบคอมพิวเตอร์, เครือข่าย Network, การเขียนโปรแกรม, การให้บริการ Cloud และอื่นๆที่คิดว่ามีประโยชน์กับผู้ที่กำลังหาข้อมูลในโลกของอินเตอร์เน็ต แล้วจะมาแชร์ให้อ่านกันเรื่อยๆนะครับ…
The post Welcome to I’m xvlnw first appeared on 1412.]]>