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


  Search this Thread
Old 01-28-2015, 12:36 PM   #1
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 -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 -j DROP

but this fails.

Could someone explain what's going on here?

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

Rep: Reputation: 1

Read man page of iptables for deleting rules

you can delete your rule

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

this is how it works


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:20 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration