iptables bash script to add offending ip's to temporary chain
Hi there all,
I have just setup a simple iptables firewall on one of my linux boxes. I have written a script that (hopefully does the following) (I am quite new to bash scripting so please excue my attempt at this script) Spec 1: Scan through my /etc/httpd/logs/access_log (apache log) 2: Filter out a particular pattern 3: output the filtered ip addresses to a text file 4: sort the text file removing duplicate entries 5: Flush iptables 6: Add the sorted / filtered ip addresses to ip tables 7: Timestamp the last time this script was run As I rotate my access_log every 24 hours offending IP's can probably get in after 24 hours which is fine. I have written the following script however it does not seem to be working properly (I got some of the code after doing some google searches) is there anyone here who could perhaps guide me in the right direction Code:
#!/bin/bash |
I messed around with it a bit - I have managed to get it working now.
Here is my code - just in case the solution I came up with is not too elegant (I'm quite sure it is not!) Code:
#!/bin/bash |
All times are GMT -5. The time now is 04:38 AM. |