LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-20-2008, 04:23 PM   #1
Ashkan_s
Member
 
Registered: Jul 2008
Distribution: Fedora
Posts: 77

Rep: Reputation: 22
Smile How to block several IPs in one command using iptables?


Hi all

I want to block several IP addresses using iptables but I don't want to block every IP in a separate command. These IP addresses are not in same subnet.Is there any way to add more than one IP in only one command without using any other program or plugin?
 
Old 08-20-2008, 04:30 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Code:
for IP in 192.168.0.10 192.168.0.100 10.200.1.200 69.56.15.20; do /sbin/iptables -A INPUT -p ALL -s $IP -j DROP; done
That's how I'd do it. Never tried to put multiple sources as IP's in one command, don't think it would take such option, only ranges in same segment or range, etc. I'd rather them be separate anyways to be honest.
 
  


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
iptables: how to block IPs by country or registry mlnutt Linux - Security 4 09-14-2007 12:22 PM
i want to block a range of ips using iptables... Vasili Linux - Security 18 09-19-2006 06:31 AM
block ips in valknut kb_ganesh Linux - Networking 0 12-01-2005 10:36 AM
How to block specific IPs? cranium2004 Linux - Networking 3 04-01-2005 09:02 AM
how to define a specific range of IPs and/or multiple IPs in an iptables rule?... TheHellsMaster Linux - Security 9 09-20-2004 10:06 AM

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

All times are GMT -5. The time now is 06:07 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