Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-30-2007, 03:07 AM
|
#1
|
Member
Registered: Jun 2002
Posts: 302
Rep:
|
iptables and groups of ips
Hi,
I was wondering if there's any way that I can specify a ips and not a range in an iptables rules. I'm aware of the iprange module, but that only helps if the IPs are a range. Below is an example of what I'm trying to do:
These 3 are in a group:
172.16.0.1
172.16.0.9
172.16.0.90
What I'm trying to do is: iptables -INPUT -p tcp -s 172.16.0.1,172.16.0.9,172.16.0.90 -j DROP
Any ideas? Thanks for your help.
|
|
|
01-30-2007, 08:23 PM
|
#2
|
Senior Member
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088
Rep:
|
You could just put each IP address as a separate rule.
Code:
iptable -INPUT -p tcp -s 172.16.0.1 -j DROP
iptable -INPUT -p tcp -s 172.16.0.9 -j DROP
iptable -INPUT -p tcp -s 172.16.0.90 -j DROP
I hope this helps
--Ian
|
|
|
01-30-2007, 09:06 PM
|
#3
|
Member
Registered: Apr 2005
Location: Canada
Distribution: Slackware 12
Posts: 184
Rep:
|
You could also create a chain.
Code:
iptables -N bannedIPs // create a new chain
// add your custom rules
iptables -A bannedIPs -p tcp -s 172.16.0.1 -j DROP
iptables -A bannedIPs -p tcp -s 172.16.0.9 -j DROP
iptables -A bannedIPs -p tcp -s 172.16.0.90 -j DROP
iptables -A INPUT -j bannedIPs // add the chain to the INPUT
Anything after // is a comment.
|
|
|
01-31-2007, 02:42 AM
|
#4
|
Member
Registered: Jun 2002
Posts: 302
Original Poster
Rep:
|
Thanks. I currently do what CrEsPo suggested, which is to create a separate chain for the IPs and then set the rules there, but I was wondering if there was anything like iprange but for non-sequential IPs. Thanks.
|
|
|
02-01-2007, 01:51 AM
|
#5
|
Member
Registered: Apr 2005
Posts: 131
Rep:
|
I run it as a bash script using variables:
bannedIPs="192.168.1.1 192.168.1.4 192.168.1.7"
for bip in $bannedIPs
do
iptables -A $bannedIPs -p tcp -s 172.16.0.1 -j DROP
|
|
|
02-01-2007, 01:52 AM
|
#6
|
Member
Registered: Apr 2005
Posts: 131
Rep:
|
I run it as a bash script using variables:
bannedIPs="192.168.1.1 192.168.1.4 192.168.1.7"
for bip in $bannedIPs
do
iptables -A $bannedIPs -p tcp -s 172.16.0.1 -j DROP
done
This allows me to easily add new ip's to the list
|
|
|
02-01-2007, 04:26 PM
|
#7
|
Member
Registered: Jun 2002
Posts: 302
Original Poster
Rep:
|
javaroast, thanks for the suggestion.
|
|
|
All times are GMT -5. The time now is 10:12 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|