LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 12-21-2007, 01:08 AM   #1
Santoshkb
Member
 
Registered: Sep 2007
Posts: 56

Rep: Reputation: 15
Same Iptable rule to be avoided?


If the new iprule match the existing .i would prefer to have one.. rather than having same entry more then once . can i have your suggestion how can the 2nd time same rule be neglected/avoided from adding in iptable.

Ex :
/sbin/iptables -t nat -A PREROUTING -p tcp -m mac --mac-source AA:BB:C1:11:EE:FF -d 192.168.10.103 --dport 80 -j REDIRECT --to 8080

if we enter twice.. the same appears twice.

Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- anywhere 192.168.10.103 MAC AA:BB:C1:11:EE:FF tcp dpt:http redir ports 8080
REDIRECT tcp -- anywhere 192.168.10.103 MAC AA:BB:C1:11:EE:FF tcp dpt:http redir ports 8080

Last edited by Santoshkb; 12-21-2007 at 01:10 AM. Reason: t
 
Old 12-21-2007, 04:53 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Santoshkb View Post
can i have your suggestion how can the 2nd time same rule be neglected/avoided from adding in iptable.
What application does add the same line then?


Quote:
Originally Posted by Santoshkb View Post
if we enter twice.. the same appears twice.
Ah. You do. Well, then don't!


BTW, AFAIK iptables rules are processed on a "first match" basis. Once a "decision" is reached for the packet it doesn't traverse the rules below unless there's something I forgot.
 
Old 12-21-2007, 05:55 AM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
There are two kinds of targets in iptables. Terminating, and non terminating.

E.g. -j ACCEPT is terminating, that means that the packet is accepted and no rules in that chain are checked anymore.

-j LOG is non terminating, after this one more rules are checked. If you have multiple targets like this they would be all checked.

Having more equal rules with terminating targets does not do any harm. Although for keeping a clear view on functionality it is better to avoid duplicates though. If you have more of the same, it gets difficult to maintain. You might leave in a rule if you expect you have removed it, or it may remain in effect when you think you changed it. And that is an iptables nightmare, really.

jlinkels
 
  


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
why are strsep and strtok() to be avoided? slzckboy Programming 6 04-27-2009 11:33 AM
input avoided in my c program. nflenz Programming 6 12-12-2006 01:47 PM
complex iptable rule help farhan Linux - Security 2 08-31-2005 09:58 PM
iptable rule for rmi bijuhpd Linux - Newbie 2 04-27-2005 12:42 AM
Help me write iptable rule to LOG gpagedar Linux - Security 1 10-01-2003 06:47 AM

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

All times are GMT -5. The time now is 08:13 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
Open Source Consulting | Domain Registration