Fedora Linux Support Community & Resources Center
  #1  
Old 5th May 2011, 12:52 PM
Vector's Avatar
Vector Offline
Banned
 
Join Date: Jul 2006
Location: Transgression
Age: 32
Posts: 1,183
linuxfirefox
Question IP Tables Drop not working

I've been googling this for a while now, and trying different examples, like:

iptables -A INPUT -s 3.2.1.0 -j DROP

iptables -A INPUT -s 3.2.1.0/24 -j DROP

service iptables restart

and none of them seem to be working. And when i view the iptables using

vi /etc/sysconfig/iptables

or

iptables -S

or

iptables -L

they are not there.

and trying to delete the rule, via

iptables -D INPUT -s 3.2.1.0 -j DROP

returns an error: iptables: Bad rule (does a matching rule exist in that chain?).

I'm new to iptables, but afaiu, those should be working, right?

I'm trying to block a range of IP Addresses from even being able to connect to my servers...

Last edited by Vector; 5th May 2011 at 01:02 PM.
Reply With Quote
  #2  
Old 5th May 2011, 01:05 PM
Evil_Bert's Avatar
Evil_Bert Offline
Retired Again - Administrator
 
Join Date: Nov 2007
Location: Reality
Posts: 3,034
linuxfedorafirefox
Re: IP Tables Drop not working

When you use the command 'iptables' like that, you are adding the rule to the active ruleset immediately. You do not need to restart the service.

If you do:
Code:
iptables -A INPUT -s 3.2.1.0 -j DROP
iptables -L
... you will see your new rule.

When you restart the service, you flush the active ruleset and re-load from the saved ruleset (in /etc/sysconfig/iptables).
__________________
.
Marching to the beat of his own conundrum.
Reply With Quote
  #3  
Old 5th May 2011, 01:07 PM
Vector's Avatar
Vector Offline
Banned
 
Join Date: Jul 2006
Location: Transgression
Age: 32
Posts: 1,183
linuxfirefox
Re: IP Tables Drop not working

Ok, so is there a command to tell it to store the active ruleset permanently? I'm man it again right now to see if i can find it...
Reply With Quote
  #4  
Old 5th May 2011, 01:11 PM
Evil_Bert's Avatar
Evil_Bert Offline
Retired Again - Administrator
 
Join Date: Nov 2007
Location: Reality
Posts: 3,034
linuxfedorafirefox
Re: IP Tables Drop not working

Yes.

Code:
iptables-save > filename
You can also edit the file /etc/sysconfig/iptables with any text editor and save manually. (Edit: That's when you actually do have to restart the service).
__________________
.
Marching to the beat of his own conundrum.
Reply With Quote
  #5  
Old 5th May 2011, 01:11 PM
Vector's Avatar
Vector Offline
Banned
 
Join Date: Jul 2006
Location: Transgression
Age: 32
Posts: 1,183
linuxfirefox
Re: IP Tables Drop not working

I will check into that when i get more time to do my "network admin crash course in bandwidth control (TC)". I was recently looking into how to set bandwidth quotas, and throughput limits. I won't have time to actually READ everything i found for another few weeks, but now i know what things that i'll need to do my homework on, when the time comes. So, at that time, i'll look into shorewall, as well, thanks.

Last edited by Vector; 5th May 2011 at 01:26 PM.
Reply With Quote
  #6  
Old 5th May 2011, 01:32 PM
Vector's Avatar
Vector Offline
Banned
 
Join Date: Jul 2006
Location: Transgression
Age: 32
Posts: 1,183
linuxfirefox
Re: IP Tables Drop not working

Ok, thanks bert. Now i've got just one more question. I read the wikipedia page on CIDR http://en.wikipedia.org/wiki/CIDR_notation and i'm still not exactly clear on how to go about blocking only 5 ip addresses at a time, instead of the entire subnet.

I understand that the 0/24 blocks all 255 possible ips, but what if i just wanted to block from .8 to .12? Would it be something like .8/4 or .8/2?

@ giulix:
yeah, that was what my "I will check into that when i get more time to ..." post was in response to (not the one from Bert). Thanks.

Wait, i think i've got it:
http://en.wikipedia.org/wiki/Classle...Domain_Routing

So, if i understand that correctly, then the answer would be .8/30

Last edited by Vector; 5th May 2011 at 01:42 PM.
Reply With Quote
  #7  
Old 5th May 2011, 01:53 PM
abhijitsarangi Offline
Registered User
 
Join Date: May 2010
Posts: 58
linuxredhatfirefox
Re: IP Tables Drop not working

Hi Guys,

Regarding the IP Tables Drop not working issue.. my suggestions would be.... once you add any kind of rule to the iptables then please ensure that you are heating these two commands....

1. service iptables save ( to save the rule)
2. Service iptables restart ( to restart the service)

then you can fell the effects of your added rules.
Reply With Quote
  #8  
Old 5th May 2011, 01:54 PM
Gödel's Avatar
Gödel Offline
Registered User
 
Join Date: Jul 2009
Location: London,England
Posts: 1,095
linuxfedorafirefox
Re: IP Tables Drop not working

iptables-save doesn't store the changes (see 'man iptables-save'), you must use

Code:
service iptables save
(as root)

edit: someone else just posted same point
Reply With Quote
  #9  
Old 5th May 2011, 01:54 PM
Evil_Bert's Avatar
Evil_Bert Offline
Retired Again - Administrator
 
Join Date: Nov 2007
Location: Reality
Posts: 3,034
linuxfedorafirefox
Re: IP Tables Drop not working

Well you can use a sub-table (as a target) in the /etc/stsconfig/iptables files if you edit it directly. This makes things easier to manage. (Technically, you can use iptables at the command line to do all this too, bit it's a PITA).

For example to block five addresses, then in the file /etc/sysconfig/iptables:

Define a sub-table (put it with the other table definitions):
Code:
:BLOCKLIST [0:0]
Define the sub-table contents with addresses or ranges you want to block:
Code:
-A BLOCKLIST -s 3.2.1.8 -j DROP
-A BLOCKLIST -s 3.2.1.9 -j DROP
-A BLOCKLIST -s 3.2.1.10 -j DROP
-A BLOCKLIST -s 3.2.1.11 -j DROP
-A BLOCKLIST -s 3.2.1.12 -j DROP
Prcessing will return to the calling table when this sub-table has been traversed (or a match occurs).

Call it from inside the INPUT table as a target:
Code:
-A INPUT -j BLOCKLIST
... then traffic processed by the above command will be sent to the target sub-table and processed there.

You should also read up on how to use 'RETURN' in iptables, which can be used to exit a table/sub-table immediately if the condition matches.

Note: It's been a while and I don't have any examples with me, so hopefully there are no syntax errors in the above.
__________________
.
Marching to the beat of his own conundrum.
Reply With Quote
  #10  
Old 5th May 2011, 01:58 PM
Evil_Bert's Avatar
Evil_Bert Offline
Retired Again - Administrator
 
Join Date: Nov 2007
Location: Reality
Posts: 3,034
linuxfedorafirefox
Re: IP Tables Drop not working

Quote:
Originally Posted by Gödel View Post
iptables-save doesn't store the changes
Sure, but if you redirect to the filename it does the same thing, which is in the code I gave. So, 'must use' is overstating the issue.

PS: Good to see you back!
__________________
.
Marching to the beat of his own conundrum.
Reply With Quote
  #11  
Old 5th May 2011, 02:06 PM
Vector's Avatar
Vector Offline
Banned
 
Join Date: Jul 2006
Location: Transgression
Age: 32
Posts: 1,183
linuxfirefox
Re: IP Tables Drop not working

@ bert:
Wow, that blocklist rule seems like it might come in handy. I think i'll do some homework on that, too, when i get a chance to do my crash course in the other above mentioned stuff.

@ the rest:
Thanks guys. I'll make use of that.
Reply With Quote
  #12  
Old 5th May 2011, 02:19 PM
William Haller Offline
Registered User
 
Join Date: Jul 2005
Age: 52
Posts: 1,013
linuxfedorakonqueror
Re: IP Tables Drop not working

I'd also recommend possibly looking at an iptables management tool like fwbuilder.

It may be overkill for what you are trying to do, but it makes management of firewalls very nice if you need to get beyond what can be done with the system configuration options. It allows you to link address tables into your firewall from a file on the disk which might be easier to manage in the long run than adding individual hosts via iptables directly (it provides scripts in the file it generates to build the iptables rules for the specified addresses).

It's really nice for managing multiple machines from one rule database and can create rule sets for various operating systems, various versions of iptables, and even a few routers all from one interface.
Reply With Quote
  #13  
Old 5th May 2011, 02:20 PM
Vector's Avatar
Vector Offline
Banned
 
Join Date: Jul 2006
Location: Transgression
Age: 32
Posts: 1,183
linuxfirefox
Re: IP Tables Drop not working

well, i'm going to be a fully-fledged web host, at some point, but only for websites using my systems. So, nothing is overkill, and thanks for the tip
Reply With Quote
Reply

Tags
drop, tables, working

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ip tables rosencrantzl337 Security and Privacy 7 5th November 2006 02:17 AM
Ip tables Saint Mike Using Fedora 2 9th July 2005 02:27 AM


Current GMT-time: 13:08 (Sunday, 19-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat