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

1027 comments:

«Oldest   ‹Older   1001 – 1027 of 1027   Newer›   Newest»
ajithrock said...

Very interesting content which helps me to get the in depth knowledge about the technology.
Mobile Apps Training Institute in Chennai | Mobile Apps Training Institute in Velachery | Mobile Apps Training Institute in Saidapet


reshmario said...

All the points you described so beautiful. Every time i read your blog content and i so surprised that how you can write so well.
Microsoft Certification Training in Chennai | Microsoft Certification Training in Velacherry | Microsoft Certification Training in Saidapet

seelan said...

Excellent post with all required information and admirable stories. Anticipating for your future posts. Keep up the Good work.

Best Embedded Systems Training Institute in Chennai |Best Embedded Systems Training Institute in Keelkattalai


Saran said...

Very good and informative article. Thanks for sharing such nice article, keep on updating such good articles.
Bootstrap Training Institute in Chennai | Bootstrap Training Institute in Velachery | Bootstrap Training Institue in Tambaram | Bootstrap Training Institue in Guindy

elearnoak said...


Thanks for your post! Through your pen I found the problem up interesting! I believe there are many other people who are interested in them just like me! Thanks your shared!... I hope you will continue to have similar posts to share with everyone! I believe a lot of people will be surprised to read this article! Best DevOps online training in hyderabad


Dhanish said...

Good content and thanks for giving nice information to read your blog.
Graphic Designing Training Institute in Chennai | Graphic Design Certification Course in Adyar

vijay said...

Excellent, Healthy and Creative content with more information required for IT and Non-IT professionals. I am looking forward for your future posts. Keep up the Good work.

Best SEO Training in Chennai | Best SEO Training in Adyar

seelan said...

Excellent, Healthy and Creative content with more information required for IT and Non-IT professionals. I am looking forward for your future posts. Keep up the Good work.

Best MBA Project Center in Chennai | Best MBA Project Center in Tambaram


Saran said...

Your blog is very informative with useful information,thanks a lot for sharing such a wonderful article,its very useful for me.keep updating your creative knowledge.!...
Blueprism Training Course in Chennai | Blueprism Training Course in Velachery | Blueprism Training Course in Tambaram

ajithrock said...

All the points you described so beautiful. Every time i read your blog content and i so surprised that how you can write so well.
Uipath Robotics Process Automation in Chennai | Uipath Robotics Process Automation in Velacherry | Uipath Robotics Process Automation in Tambaram

reshmario said...

Your Blog is really awesome with useful and helpful content for us.Thanks for sharing ..keep updating more information.
QA Training Training in Chennai | QA Testing Training in Tambaram | QA Testing Training in Velachery | QA Testing Training in Guindy

Saran said...

This blog very easily understandable. Thanks for sharing such an informative post with us.This is a nice post in an interesting line of content.
Tally Training Course in Chennai | Tally Training Course in Velcherry | Tally Training Course in Pallikaranai

seelan said...

Nice Post! It is really interesting to read from the beginning and Keep up the good work and continue sharing like this.

Best MATLAB Training in Chennai | Best MATLAB Training in Velachery


reshmario said...

Very informative blog. Thanks for sharing such good information and keep on updating.This is a nice post in an interesting line of content.Thanks for sharing this article.
PCB Training in Chennai | PCB Training in Velcherry | PCB Training in Guindy

ajithrock said...

I have read your blog its very attractive and impressive. I like it your blog...
Web Design And Development Training in Chennai | Web Design And Development Training in Velcherry | Web Design And Development Training in Taramani

sindhu sree said...

Wonderful article.It is to define the concepts very well.Clearly explain the information.It has more valuable information for

encourage me to achieve my career goal.

Best Android Training institute in kanchipuram

sindhu sree said...

Wonderful article.It is to define the concepts very well.Clearly explain the information.It has more valuable information for encourage me to achieve my career goal.

Best Android Training institute in kanchipuram

akhilpatel said...

Thanks for your post! Through your pen I found the problem up interesting! I believe there are many other people who are interested in them just like me! Thanks your shared!... I hope you will continue to have similar posts to share with everyone! I believe a lot of people will be surprised to read this article! DevOps online training in hyderabad

ajithrock 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.
PHP and MYSQL Training Course in Chennai | PHP and MYSQL Training Course in Velcherry | PHP and MYSQL Training Course in OMR

Saran said...

Very informative blog. Thanks for sharing such good information and keep on updating.This is a nice post in an interesting line of content.Thanks for sharing this article.
VLSI Training in Chennai | VLSI Training in Velcherry | VLSI Training in OMR

reshmario said...

It's very great post...Thanks for sharing such an informative post..
Thanks for sharing this valuable information.. I saw your website and get more details..Nice work...
HP and QTP Training Course in Chennai | HP and QTP Training Course in Velcherry | HP and QTP Training Course in Pallavaram

Priyanka said...

Attend The Digital Marketing Course Bangalore From ExcelR. Practical Digital Marketing Course Bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Digital Marketing Course Bangalore.
Digital Marketing Course Bangalore

vijay said...


Very Informative...Glad to find your blog...Keep Sharing...

Java Script Course in Chennai | Java Script Course in Medavakkam


Priyanka said...

Attend The Machine Learning course Bangalore From ExcelR. Practical Machine Learning course Bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Machine Learning course Bangalore.
Machine Learning course Bangalore

uma said...



Thank you for your information. I have got some important suggestions from it. Keep on sharing.
Best Computer Service in Chennai | Best Computer Service in Kovilambakkam

madhu said...

You have provided a nice article, Thank you very much for this one. And I hope this will be useful for many people. And I am waiting for your next post keep on updating these kinds of knowledgeable things
Android Training in Chennai
Android Course in Chennai
App Development Course in Chennai
Android Development Course in Chennai
Android App Development Course in Chennai

madhu said...

You have provided a nice article, Thank you very much for this one. And I hope this will be useful for many people. And I am waiting for your next post keep on updating these kinds of knowledgeable things
App Development Course in Chennai
Android Development Course in Chennai
Android Training Institutes in Bangalore
Android App Development Course in Bangalore
Android Course in Coimbatore
Android App Development Course in Coimbatore
Android Course in Madurai

«Oldest ‹Older   1001 – 1027 of 1027   Newer› Newest»

Post a Comment

Popular Posts