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

89 comments:

Mobile App Developers said...

Great article, Thanks for your great information, the content is quiet interesting. I will be waiting for your next post.

Anonymous said...

Really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info! , Regards, servicenow training in hyderabad

jatin tyagi said...

I have been reading out a lot of your articles.
I will certainly bookmark your Blog.
Free Devops Training
Dell Boomi Training

GST Registration in Delhi said...

Nice post, things explained in details. Thank You.

John Nash said...

Excellent Blog very imperative good content, this article is useful to beginners and real time Employees. DevOps Online Training

Interview Gig said...

This is an awesome post. Really very informative and creative contents. These concept is a good way to enhance the knowledge. Here You can find some Frequently Asked DevOps Interview Questions and Answers with explanation

Chef Interview Questions and Answers

Docker Interview Questions and Answers

GIT Interview Questions and Answers

Jenkins Interview Questions and Answers

Maven Interview Questions and Answers

Nagios Interview Questions and Answers

Puppet Interview Questions and Answers

nasreen basu said...

interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts,Thanks a million once again, Regardsadobe cq5 training in hyderabad
servicenow training in hyderabad
devops training in hyderabad

santhosh k said...

The blog gave me idea to block consecutive IP address using scripts my sincere thanks for sharing
this post please continue to share this post
Devops Training in Bangalore
Devops Training in BTM Layout
Devops Training in Marathahalli

Sadiya Moshin said...

Block consecutive IP address using bash script or perl script.. Nicely Explained with images.. Great Job!!
Devops Training
Machine Learning Training

arvind said...

Thanks for sharing this informative blog..
best dijango training in Bangalore.

Solomon said...

Thanks for sharing this wonderful blog..best selenium training in bangalore

viswanath said...

very good blog blockchain training in bangalore
python training in bangalore

Suresh R said...

Excellent blog artificial intelligence training in bangalore

mary Brown said...

I am technology Enthusiast. Your blog is really awesome, attractive and impressive. I like the way you think. it is very useful for Java SE & Java EE Learners. Your article adds best knowledge to our Java Online Training in India. or learn thru Java Online Training in India Students. or learn thru JavaScript Online Training in India. Appreciating the persistence you put into your blog and detailed information you provide. Kindly keep blogging.

DAVIS MILLER said...

Those guidelines additionally worked to become a good way to
recognize that other people online have the identical fervor like mine
to grasp great deal more around this condition.


AWS Training in Bangalore


AWS Training in Bangalore

Renith Harsan said...

Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here"Oracle Training in Chennai".

ASO Services said...

Thanks for your marvelous posting! It is very useful and good. Come on. I want to introduce the best aso services for you, I try it and I feel it is so good to rank app to top in app store search results, have you ever heard it?

DAVIS MILLER said...

I believe there are many more pleasurable opportunities ahead for
individuals that looked at your site.


aws training in chennai



aws training in bangalore

Mary Adlena said...

You made some good points there. I did a search on the topic and found most people will agree with your blog.
Android Project Center in Chennai | Android Project Center in Velachery

john kevin said...

Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
java training in bangalore

java training in bangalore

keith kristoper 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.
python training in bangalore

sam said...

Thanks for sharing such a nice article.
Austere Technologies | Best Cloud Solution Services Company

ram chinna said...

Excellent article and thanks for sharing good articles. get more informative content Mobile application development Services

massil said...

Very good informative article. Thanks for sharing such nice article, keep on up dating such good articles.

ORACLE CLOUD SERVICES FOR APPLICATION DEVELOPMENT | MASSIL TECHNOLOGIES

PLC Training Chennai said...

PLC Training in Chennai | PLC Training Institute in Chennai | PLC Training Center in Chennai | PLC SCADA Training in Chennai | PLC SCADA DCS Training in Chennai | Best PLC Training in Chennai | Best PLC Training Institute in Chennai | PLC Training Centre in Chennai | PLC SCADA Training in Chennai | Automation Training Institute in Chennai | PLC Training in Kerala

ram chinna said...

wow...nice blog, very help full information. Thanks for sharing.

Best Digital Transformation Services | DM Services | Austere Technologies

masi said...
This comment has been removed by the author.
masi said...

REALLY VERY EXCELLENT INFORMATION. I AM VERY GLAD TO SEE YOUR BLOG FOR THIS INFORMATION. THANKS FOR SHARING. KEEP UPDATING.

NO.1 APP DEVELOPMENT SERVICES | MASSIL TECHNOLOGIES

masi said...

Great information. Thanks for sharing, keep updating.

Best Mobility Services | Austere Technologies

AUSTERO said...

Excellent information, Thanks for sharing.

Best IT Security Services | Austere Technologies

SEO LHR said...
This comment has been removed by the author.
desh said...

Great article, really very helpful content you made. Thank you, keep sharing.

For your Best career in commerce | Avinash College Of Commerce

austere said...

Wow...What an excellent informative blog, really helpful. Thank you.

Software Testing | Austere Technology

satheesh sutharapu said...

Excellent information you made in this blog, very helpful information. Thanks for sharing.

chartered accountant | Avinash college of commerce

avinash said...

Nice blog with excellent information. Thank you, keep sharing.

chartered accountant course in Hyderabad | Avinash college of commerce

avinash said...

Great article, really very helpful content you made. Thank you, keep sharing.

Best Degree Colleges Hyderabad | Avinash College of Commerce

Nikitha Raja said...

Really very great information for that post, am amazed and then more new information are get after refer that post. I like that post.

Python Training in Chennai | Python Training Institute in Chennai

Avinash said...

Very good informative blog, keep sharing.

Best junior college in Hyderabad | Avinash College of commerce

Avinash said...

Hi Thanks for the nice information its very useful to read your blog. We provide best Block Chain Services

sandy said...

Thank you for sharing this valuable information. But get out of this busy life and find some peace with a beautiful trip book best Andaman honeymoon packages

Guest Posting World said...

Nice and informative Blog post. Keep writing!!

Avinash College Of Commerce said...

Hi Thanks for the nice information its very useful to read your blog. We provide best Finance Training in Hyderabad

Nisha Premrahul said...

This is a really great informative blog. Keep Sharing.
Graphic Designing Training Course in Chennai | Graphic Designing Training Course in Velachery

krishna swamy said...

Hi Thanks for the nice information its very useful to read your blog.
No.1 UIPath Training Institute in Chennai | No.1 UIPath Training Institute in Velachery

Mary Adlena said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as
RPA Training Course in Chennai | RPA Training Course in Velachery

gowsalya said...

Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
www.besanttechnologies.in/devops-training-in-bangalore.html

sandy said...

Thank you for sharing this valuable information. But get out this busy life and find some peace with a beautiful trip. book ANDAMAN HOLIDAY PACKAGES @ 35999

sandy said...

Thank you for sharing this valuable information. But get out this busy life and find some peace with a beautiful trip. book CHEAP ANDAMAN PACKAGES @9999

Mary Adlena said...

Hi Thanks for the nice information its very useful to read your blog
Graphic Designing Training Institute in Chennai | Graphic Designing Training Institute in Velachery

krishna swamy said...

I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.
Blue Prism Robotic Process Automation in Chennai | Blue Prism Robotic Process Automation in Velachery

sandy said...

Thank you for sharing this valuable information. But get out this busy life and find some peace with a beautiful trip. book Andaman Tourism

sandy said...

Thank you for sharing this valuable information. But get out this busy life and find some peace with a beautiful trip. book Best Travel Agency In India

Avinash said...

Good information.

B.com Integrated Courses | Avinash College of commerce

krishna swamy said...

Awesome article.The information I have been searching precisely. It helped me a lot, thanks. Keep coming with more such informative article. Would love to follow them.
BluePrism Training Institute in Chennai | UIPath Training Institute in Chennai | Automation Anywhere Training Institute in Chennai

sandy said...

Hi Thanks for the nice information its very useful to read your blog. We provide About Best Software Development Services

Preethi Evolet said...

thank you for sharing valuable information.
Python Course in bangalore

Nisha Premrahul said...

Very nice post.I really like the post.
Graphic Designing Training Institute in Chennai | UIPath Certification Training in Chennai

Unknown said...

Good one.I appreciate you for sharing this knowledge.Thank you so much for the examples.Its very helpful for me and newbies.I learned much
ISTQB Certifications Exams Course in Chennai | QA Testing in Meenambakkam

kalai hai said...

This is a really great informative blog. Keep Sharing.
No.1 Microsoft Azure Training Institute in Chennai | No.1 Microsoft Azure Training Institute in Velachery

rajendran said...

Good one.I appreciate you for sharing this knowledge.Thank you so much for the examples.Its very helpful for me and newbies.I learned much .
Certified Ethical Hacking Training in Chennai | Blue Prism Training Institute in Chennai

nikile siva said...

thanks for sharing blog to us
ANDROID TRAINING INSTITUTE IN CHENNAI | ANDROID TRAINING INSTITUTE IN VELACHERY

sandy said...

Thank you for sharing this valuable information. But get out this busy life and find some peace with a beautiful trip. book ANDAMAN TOUR PACKAGE@14599/

nikile siva said...

Blog was nice
DOTNET TRAINING INSTITUTE IN CHENNAI | DOTNET TRAINING INSTITUTE IN VELACHERY

gowsalya saranya said...

Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
Digital Marketing Training in Chennai

Aws Training in Chennai

Selenium Training in Chennai

johnsy sai said...

Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
Digital Marketing Training in Bangalore

digital marketing training in tambaram

digital marketing training in annanagar

digital marketing training in marathahalli

digital marketing training in rajajinagar

Digital Marketing online training

sandy said...

Hi Thanks for the nice information its very useful to read your blog. We provide best Find All Isfs Courses

sandy said...

Hi Thanks for the nice information its very useful to read your blog. We provide best Massil Technologies

Mouni yoga said...

Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me.
python training in rajajinagar
Python training in btm
Python training in marathahalli

thomas hardy said...

Interesting article..Thanks for sharing..
Robotics Project Center Training in Chennai | Best Robotics Project Course in Tambaram

nikile siva said...

good post

fawaz shaik said...

Quite interesting post,Thanks for sharing the information.Keep updating good stuff...
Certified Ethical Hacking Training in Chennai | Certified Ethical Hacking Training in Velachery

deepti said...

Thanks for your marvelous posting! It is very useful and good.
CLOUD COMPUTING Classes in Chennai | CLOUD COMPUTING Courses in Velachery

Saravanan said...

It was really good information shared from the your post.It was really nice
Selenium Testing Course in Chennai | Selenium Testing Course in Velachery

Ram priya said...

Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
Data Science training in kalyan nagar
Data Science training in OMR
selenium training in chennai
Data Science with Python training in chenni
Data Science training in chennai
Data science training in velachery

harsha hai said...

It is really great work and the way in which you are sharing the knowledge is excellent. Thanks for your informative article
No.1 Automation Anywhere Training Institute in Chennai | No.1 Automation Anywhere Training Institute in Kanchipuram | No.1 Automation Anywhere Training Institute in Velachery

prabash said...

Your new valuable key points imply much a person like me and extremely more to my office workers. With thanks; from every one of us.
No.1 Blue Prism Training Institute in Chennai | No.1 Blue Prism Training Institute in Velachery | No.1 Blue Prism Training Institute in Kanchipuram

Nisha Premrahul said...

Hi, I am really happy to find such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post.
Automation Anywhere Training with Placement in Chennai | Automation Anywhere Training with Placement in Tambaram

Avinash said...

Best informative blog. Thank you.

cima courses in hyderabad | ISFS

Saranya Karthik said...

It’s always so sweet and also full of a lot of fun for me personally and my office colleagues to search your blog a minimum of thrice in a week to see the new guidance you have got.
JAVA and J2EE Training Institute in Chennai | JAVA and J2EE Training Institute in Velachery

bala kumar said...

It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read.
No.1 Automation Anywhere Training Institute in Chennai | No.1 Automation Anywhere Training Institute in Velachery

sudha P said...

I likable the posts and offbeat format you've got here! I’d wish many thanks for sharing your expertise and also the time it took to post!!
java training in chennai

java training in marathahalli | java training in btm layout

Avinash said...

Excellent informative blog, keep for sharing.

Best System Integration services | Massil Technologies

Rohil singh said...

Great post and informative blog.it was awesome to read, thanks for sharing this great content to my vision.
Good discussion.
PMP Training Course in Bangalore
PMP Training Course in Dammam
PMP Training Course in Dubai
PMP Training Course in Jeddah
PMP Training Course in Riyadh

Avinash said...

Excellent informative blog, keep sharing.

CA institute in hyderabad | Avinash College of Commerce

Anexas Europe said...

Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us. Do check Six Sigma Training in Bangalore | Six Sigma Training in Dubai & Get trained by an expert who will enrich you with the latest trends.

Genga Savitha said...

Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..
angularjs Training in bangalore

angularjs Training in bangalore

angularjs Training in btm

angularjs Training in electronic-city

angularjs online Training

angularjs Training in marathahalli

Avinash said...

Excellent informative blog, Thanks for sharing.

cs institutes in hyderabad | Avinash College of Commerce

satheesh sutharapu said...

Hi Thanks for the nice information its very useful to read your blog. We provide best Association Of Chartered Certified Accountants

teja said...

Simply wish to say your article is as astonishing. The clarity in your post is simply great, and I could assume you are an expert on this subject. Thanks a million, and please keep up the gratifying work.
No.1 Blue Prism Training Institute in Chennai | No.1 Blue Prism Training Institute in Kanchipuram

Post a Comment

Popular Posts