This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
networking:linux:bad_bot_trap [2013/09/26 11:35] gcooper |
networking:linux:bad_bot_trap [2013/10/13 14:59] (current) gcooper |
||
---|---|---|---|
Line 6: | Line 6: | ||
We use Fail2Ban to block bad bots. | We use Fail2Ban to block bad bots. | ||
+ | |||
+ | ===== robots.txt ===== | ||
+ | |||
+ | Misbehaving bots may access areas of your web site even if you tell then not to. That's what we key on here. | ||
:!: First, change to your web root folder. | :!: First, change to your web root folder. | ||
Line 20: | Line 24: | ||
</ | </ | ||
- | < | + | ===== Web Site Header ===== |
- | mkdir bot-trap | + | |
- | </ | + | |
- | '' | + | We use a tiny image for embedding the hidden link. |
< | < | ||
Line 32: | Line 34: | ||
</ | </ | ||
- | Edit your HTML header (''< | + | Edit your HTML header (''< |
< | < | ||
Line 40: | Line 42: | ||
</ | </ | ||
- | Now we create a file so as not to pollute the error logs. Change the URL to your own domain: | + | ===== bot-trap Folder ===== |
+ | |||
+ | Now we create | ||
< | < | ||
+ | mkdir bot-trap | ||
cat << EOF >> bot-trap/ | cat << EOF >> bot-trap/ | ||
< | < | ||
Line 52: | Line 57: | ||
</ | </ | ||
EOF | EOF | ||
+ | |||
+ | chown -R apache.apache bot-trap | ||
</ | </ | ||
+ | |||
+ | ===== Fail2Ban ===== | ||
Add another regex to the fail2ban '' | Add another regex to the fail2ban '' | ||
< | < | ||
- | $ vi / | + | vi / |
failregex = ^< | failregex = ^< | ||
- | ^< | + | ^< |
+ | </ | ||
+ | |||
+ | Be sure to enable the '' | ||
+ | |||
+ | < | ||
+ | service fail2ban restart | ||
+ | </ | ||
+ | |||
+ | ===== Test Fail2Ban Filter ===== | ||
+ | |||
+ | Modify your log path as necessary: | ||
+ | |||
+ | < | ||
+ | fail2ban-regex ../ | ||
+ | </ | ||
+ | |||
+ | Check the Fail2Ban log: | ||
+ | |||
+ | < | ||
+ | tail -f / | ||
+ | </ | ||
+ | |||
+ | :!: If Fail2Ban fails to parse your log files at all, try setting '' | ||
+ | |||
+ | ===== Parse IPTables Rules for List of Banned IPs ===== | ||
+ | |||
+ | < | ||
+ | iptables -nL |grep "DROP | ||
</ | </ |