LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 10-13-2010, 06:24 AM   #1
Hariharan
Member
 
Registered: Nov 2004
Location: Bangalore
Posts: 64

Rep: Reputation: 0
Shell script for geoiplookup cmd


Hi All,

I ve the following Script which is used to Block the refused connect IP's......
`cat /var/log/secure | grep "refused connect" |awk '{print $9}'|sed 's/::ffff://g'|uniq -c | sort -nr |head -8 | awk '{print $2}' >/root/BlockedIP`
for IP in `cat /root/BlockedIP`;
do
iptables -A INPUT -s $IP -j DROP
done

This code show only IP's in BlockedIP file.

In this script i need to add "geoiplookup".
what i want mean i wannna to show the country name in BlockedIP file.
How to use the geoiplookup command...?
Plz any one guid me to complete the script.

Thanks,
Hariharan V
 
Old 10-13-2010, 06:59 AM   #2
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: RHEL/Ubuntu/Debian/Fedora/Centos/K3OS
Posts: 1,159
Blog Entries: 4

Rep: Reputation: 149Reputation: 149
If /root/BlockedIP contains IP then same way you do


for IP in `cat /root/BlockedIP`;
do
echo $(geoiplookup $IP)
 
Old 10-14-2010, 12:59 AM   #3
Hariharan
Member
 
Registered: Nov 2004
Location: Bangalore
Posts: 64

Original Poster
Rep: Reputation: 0
Hi
Thanks.....its working
How to display with that IP?
is display only country name,i wanna to display both ip and country name.
 
Old 10-14-2010, 01:04 AM   #4
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: RHEL/Ubuntu/Debian/Fedora/Centos/K3OS
Posts: 1,159
Blog Entries: 4

Rep: Reputation: 149Reputation: 149
$IP is the IP;isnt it?

try
Quote:
echo $IP
 
Old 10-14-2010, 01:13 AM   #5
Hariharan
Member
 
Registered: Nov 2004
Location: Bangalore
Posts: 64

Original Poster
Rep: Reputation: 0
Thank uuuuu.......
its working.....
can u give me some e-book to learn shell scripts and basic python
 
  


Reply



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
PHP - Ping test in shell/cmd window baddah Programming 1 03-04-2010 04:10 AM
Shell script/cmd to remove old folders in a directory? exxoid Linux - Newbie 1 03-29-2009 01:38 PM
bash shell cmd msg w/dd tschima Linux - Newbie 4 07-12-2007 02:47 AM
How to input several cmds to interactive apps through one shell cmd? kornerr Linux - General 4 01-01-2006 01:05 PM
Awk and Shell CMD Output xanthium Programming 16 04-24-2002 06:13 AM

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

All times are GMT -5. The time now is 11:17 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
Open Source Consulting | Domain Registration