LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-28-2015, 12:36 PM   #1
forrie
Member
 
Registered: Sep 2003
Distribution: RedHat
Posts: 41

Rep: Reputation: 15
Deleting iptables rules that contain comments


Either I've found a bug, or something else isn't working correctly. This is on CentOS 5.11.

Normally, I will add a rule to the INPUT chain like:

iptables -I INPUT 1 111.222.333.0/24 -j DROP

This is easily deleted with the reverse:

iptables -D INPUT 111.222.333.0/24 -j DROP

recently, I began adding comments to various rules, so I can track them.

iptables -I INPUT 1 -s 204.92.31.0/255.255.255.0 -m comment --comment "012815 SPAM ABUSE " -j DROP

but if I attempt to delete the rule based on the above syntax, it fails. From a basic parsing perspective, I would think that this should just work -- or this is a bug. I don't think it would be realistic for someone to have to type out the entire comment in order for the rule to be matched for:

iptables -D INPUT 204.92.31.0/24 -j DROP

but this fails.

Could someone explain what's going on here?


Thanks.
 
Old 01-29-2015, 02:36 AM   #2
dubnik
Member
 
Registered: Dec 2006
Location: Slovakia
Distribution: Red Hat
Posts: 48

Rep: Reputation: 1
hi

Read man page of iptables for deleting rules

you can delete your rule

iptables -D INPUT -s 204.92.31.0/255.255.255.0 -m comment --comment "012815 SPAM ABUSE " -j DROP //without line number
or
iptables -D INPUT 1 //detele rule using line number

this is how it works
 
  


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
How can I tell if these iptables rules already exist? iptables -P INPUT ACCEPT iptabl abefroman Linux - Security 1 10-21-2013 03:00 PM
[SOLVED] during system startup, iptables rules not loaded from /etc/sysconfig/iptables danyim Linux - Security 3 04-13-2013 02:09 AM
[SOLVED] deleting iptables rules by matching mark siddhiqbcs Linux - Newbie 1 09-19-2012 08:12 AM
Will Deleting 70-persistent-cd.rules and 70-persistent-net.rules Work As a "Live USB" Konphine Linux - General 1 10-09-2011 03:55 PM
comments on iptables rng Linux - Security 7 10-05-2011 11:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:47 PM.

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