block consecutive IP address using scripts



How to block long list of consecutive IP address?
How to call linux route command inside a script?
How to block consecutive IP address using bash script or perl script?
How to block local IP address permanently?

The are times that a server does not need to listen and process any TCP/UDP request for a long list of consecutive local IP addresses.

This blog entry provides a starting point of creating server scripts to block a long list of consecutive IP address from the server for permanent blocking.

To start, launch your fave editor and create a IPblock.sh bash script like with contents similar to the next few lines. This blog entry assumes that you have bash shell and perl currently installed from the machine.
From below example, we are permanently blocking IP address from
192.168.0.10 to 192.168.0.254.
Here's a simple sample script that does the job.
#!/bin/bash
echo Blocking started ...

for ((i=10;i<=254;i=i+1)); do /sbin/route add -host 192.168.0.$i reject done echo Done
This can also be accomplished using perl script which does the same function. Create a separate IPblock.pl perl script like so.
#!/usr/bin/perl -w

my $i;
for ($i=10; $i<=254; $i++ ) { system ("/sbin/route del -host 192.168.0.$i reject"); } }
Make sure these scripts are root executable like so
# chmod 700 IPblock.sh
# chmod 700 IPblock.pl
Now, to execute individually
# ./IPblock.sh
# ./IPblock.pl
Additionally, the above scripts can be scheduled for regular execution if you need them so by using crontab utility.




Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

229 comments:

«Oldest   ‹Older   201 – 229 of 229   Newer›   Newest»
ramya said...

Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on updating...
Summer Course Training in Chennai | Summer Courses for School Students in Chennai | Vacation Course in Velachery | Vacation Classes in Adyar | Summer Courses in Guindy

bharathi dasan said...

I believe there are many more pleasurable opportunities ahead for
individuals that looked at your site.Best vacation classes traning for Students

Bala said...

Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.
Vacation Courses in Chennai | Vacation Courses in Meenampakkam

Vimal said...

enjoyed reading the Post. It was very informative and useful.
Vacation Course Training Institute in Chennai | Vacation Course Training Institute in Pallavaram

roja said...

Good Blog....Thanks for sharing your informative and amazing blog with us, it’s very helpful for everyone.
Summer Course Training in Chennai | Summer Courses for School Students in Chennai | Vacation Course in Perungudi | Vacation Classes in Chrompet | Summer Courses in Palavanthangal

Nancy said...

Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it
Summer courses in Chennai | Summer courses in Nanganallur

Bala said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge.
Vacation Courses in Chennai | Vacation Courses in Perungudi

Nithya said...

Thanks its Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us.
Vacation Training Course in Chennai | Vacation Training Course in Adyar

uma said...

Very good and informative article. Thanks for sharing such nice article, keep on updating such good articles.good training

Sanjay said...

Very good and informative article. Thanks for sharing such nice article, keep on updating such good articles.
Vacation Course Training Institute in Chennai | Vacation Course Training Institute in Madipakkam

Jerina said...

Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
Summer Course in Chennai | Summer Course in Medavakkam

Deepa said...

Very informative blog. Thanks for sharing such good information and keep on updating.
Summer Course Training in Chennai | Summer Courses for School Students in Chennai | Vacation Course in Adyar | Summer Courses in Saidapet | Summer Course in Training in OMR

ramakrishnan said...

Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it
Vacation Courses in Chennai | Vacation Courses in Nanganallur.

ramakrishnan said...

Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it
Vacation Courses in Chennai | Vacation Courses in Nanganallur.

ajay said...

Your blog is really amazing with smart and cute content. Keep updating such an excellent article.
Summer Course in Chennai | Summer Courses for School Students in Chennai | Vacation Course in Nanganallur | Summer Courses Training in Palavanthangal | Summer Course in Porur

Anu Ram said...

Thank you so much for sharing such an amazing post with useful information with us. Keep updating such a wonderful blog….
Best Vacation Classes in Kanchipuram

nikitha josh said...

Very useful information, Keep posting more blog likes this, Thank you.
Aviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
Aviation Courses in Chennai
cabin crew training institute in Chennai
airlines training Chennai
Ground staff training in Chennai

roja said...

Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.
AWS Training Center in Chennai | AWS Certification in Velachery | AWS Training in Nanganallur | AWS Training in Palavanthangal | AWS Training in Medavakkam

ramya said...

Your blog is very informative with useful information, thanks a lot for sharing such a wonderful article, it’s very useful for me. Keep updating your creative knowledge....
JAVA Course in Chennai | JAVA Course in Velachery | Java Course in Pallikaranai | Java Course in Taramani | Java Course in Madipakkam | Advanced Java Training in Keelkattalai

Deepa said...

This is really too useful and have more ideas from yours. Keep sharing many techniques. Eagerly waiting for your new blog and useful information. Keep doing more.
Python Training in Taramani | Python Training in Guindy | Python Certification Centers in Chennai | Python Training in Pallikaranai | Python Certification Training in Velachery

ajay said...

Great post and informative blog. It was awesome to read, thanks for sharing this great content to my vision.
Selenium Training in Chennai | Selenium Certification Center in Velachery | Selenium Training Center in Taramani | Selenium Exam Center in Keelkattalai

ramya said...

Good and more informative Blog. This content was easily understand and unique. Thanks for sharing this post.
Selenium Training Institute in Chennai | Selenium Training in OMR | Selenium Course in Velachery | Selenium Certification in Perungudi | Selenium Training in Adyar | Selenium Training Center in Saidapet

Blessy john said...

I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
Best Python Training Institute in Kanchipuram

Jasmine said...

I have read your blog it’s very attractive and impressive. I like it your blog...
Java Training Center in Chennai | Java Course in Velachery | Java Training Institute in Saidapet | Java Training in Adyar

Deepa said...

Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating...
AWS Certification in Chennai | AWS Training in Tambaram | AWS Training in Meenambakkam | AWS Training in Porur | AWS Exam Center in Velachery

roja said...

Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on updating...
Microsoft Azure Training in Chennai | Microsoft Azure Training in Taramani | Microsoft Azure Training in Guindy | Microsoft Azure Training in Pallikaranai | Microsoft Azure Training in Velachery | Microsoft Azure Training in Nanganallur | Microsoft Azure Training in Tambaram | Microsoft Azure Training in Keelkattalai

Janaki said...

Thanks for posting this useful content, Good to know about new things here,Keep updating your blog...
Python Training Institute in Velachery

Deepa said...

Really very nice blog information for this one and more technical skill is improved, I like that kind of post.
Python Exam Center in Chennai | Python Exams in Velachery | Python Exam Center in Taramani | Python Certification in Chennai

Seetha said...

I have read your blog. It’s very informative and useful blog. You have done really great job. Keep update your blog.
Best Microsoft Azure Training Institute in Chennai | Best Microsoft Azure Training Institute in Pallikaranai

«Oldest ‹Older   201 – 229 of 229   Newer› Newest»

Post a Comment

Popular Posts