LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-19-2012, 07:38 AM   #1
siddhiqbcs
LQ Newbie
 
Registered: Sep 2012
Posts: 1

Rep: Reputation: Disabled
deleting iptables rules by matching mark


Hi,

Is there any way to delete the IPtables rules which are match with the marking.

for example i've some four rules in the iptables and among those four rules two are set with the marking 0x1 and another are set with the marking 0x2.

Now how can i delete the rules which are set with the marking 0x1 alone...

iptables -t nat -I PREROUGING -p tcp -m mark --mark 0x1 -d www.google.com -j DROP
iptables -t nat -I PREROUGING -p tcp -m mark --mark 0x1 -d www.yahoo.com -j DROP

iptables -t nat -I PREROUGING -p tcp -m mark --mark 0x2 -d www.google.com-j DROP
iptables -t nat -I PREROUGING -p tcp -m mark --mark 0x2 -d www.yahoo.com -j DROP


The above for are my rules.. Now i want to delete the rules which are set with the mark 0x1 alone...

Thanks..

Last edited by siddhiqbcs; 09-19-2012 at 07:40 AM. Reason: to put sample
 
Old 09-19-2012, 09:12 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
Code:
/sbin/iptables -n -t nat --line-numbers -L PREROUTING|tac| awk '/match 0x1/ {print "/sbin/iptables -t nat -D PREROUTING "$1}' #|/bin/sh
 
1 members found this post helpful.
  


Reply


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
Will Deleting 70-persistent-cd.rules and 70-persistent-net.rules Work As a "Live USB" Konphine Linux - General 1 10-09-2011 04:55 PM
Applying iptables fw rules failed when using MARK target nnes Linux - Security 2 05-20-2011 05:48 AM
deleting a line matching two or more regexp in bash, sed maybe? patolfo Programming 21 05-21-2010 01:30 PM
libipt_time.so Error for time matching in iptable rules baig Linux - Networking 1 04-19-2009 03:03 PM
LXer: Meet Mark Radcliffe: The man who rules open source law LXer Syndicated Linux News 0 09-01-2007 09:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration