LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-31-2010, 05:11 AM   #1
HariharanV
Member
 
Registered: Aug 2010
Posts: 49

Rep: Reputation: 0
need a shell script for creating report


Hi All,

`cat /var/log/secure | grep "refused connect" |awk '{print $9}'|sed 's/::ffff://g'|uniq -c | sort -nr |head -2 | awk '{print $2}' >/root/sample`
for IP in `cat /root/sample`;
do
iptables -A INPUT -s $IP -j DROP
done



With this script it ll create a file sample,in that file generate the most number of refused connect IP's, with that i need a shell script to Create a report based on the Blocked IP list.
Report should contain the following :

--- Date, Blocked IP, country of origin, no of attempts, status


Thanks,
Hariharan V.
 
Old 08-31-2010, 08:19 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,394
Blog Entries: 55

Rep: Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565
Quote:
Originally Posted by HariharanV View Post
`cat /var/log/secure | grep "refused connect"
If that's SSH or another service I suggest you use 'fail2ban' instead. No need to reinvent the wheel again and w/o managing the results.


Quote:
Originally Posted by HariharanV View Post
awk '{print $2}' >/root/sample`
Root isn't a user account to abuse by have processes save files in /root. For temporary storage not exceeding certain sizes you could avoid some disk I/O and use /dev/shm, else use /var. That's what it's for.


Quote:
Originally Posted by HariharanV View Post
with that i need a shell script to Create a report based on the Blocked IP list.
Sure but what have you tried yourself? Post whatever you got (preferably in BB code tags) and you may receive constructive comments.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to extract single report by pattern, then both backward and forward ykheong Linux - Newbie 8 02-22-2010 02:20 AM
[SOLVED] Ping shell script to report high rtt celembor Linux - Software 11 12-02-2009 08:12 AM
Creating a back up shell script keef12345 Linux - General 1 11-03-2007 06:24 PM
Help with creating a shell script windisch Programming 66 10-07-2005 07:26 AM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 11:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration