All of lore.kernel.org
 help / color / mirror / Atom feed
* creating one rule for both tcp and udp?
@ 2006-08-25 17:59 Matt Singerman
       [not found] ` <265CD2F3F15DEDF58A73A320@localhost>
  2006-08-26 18:47 ` Pascal Hambourg
  0 siblings, 2 replies; 3+ messages in thread
From: Matt Singerman @ 2006-08-25 17:59 UTC (permalink / raw)
  To: netfilter

Hi all,

I was wondering, if I wanted to fliter packets on a specific port, can I 
write a single rule to work on both tcp and udp traffic, or will I have 
to write one rule for each?

Support, for instance, that I want to allow TCP and UDP packets from any 
host on port 548 to a machine with IP address 192.168.1.4, could I write 
a rule like:

-A FORWARD -s 0/0 -d 141.161.111.203  -p all --dport 548 -j ACCEPT

(please note, I am just using port 548 as an example.)

Now, I know that this doesn't work, because I tried it :)  I can back 
the error:

iptables v1.3.5: Unknown arg `--dport'

I am guessing that is because "-p all" include ICMP, which doesn't take 
the --dport argument.  Am I wrong about that?

So, to do this, I would have to do two rules:

-A FORWARD -s 0/0 -d 141.161.111.203  -p tcp --dport 548 -j ACCEPT
-A FORWARD -s 0/0 -d 141.161.111.203  -p udp --dport 548 -j ACCEPT

Now, I would prefer not to do this, because in a lot of places, I would 
have to add a whole lot of rules.  So, I ask, is there a way to comine 
TCP and UDP into a single rule?

Thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: creating one rule for both tcp and udp?
       [not found] ` <265CD2F3F15DEDF58A73A320@localhost>
@ 2006-08-25 18:05   ` Matt Singerman
  0 siblings, 0 replies; 3+ messages in thread
From: Matt Singerman @ 2006-08-25 18:05 UTC (permalink / raw)
  To: David Lang; +Cc: netfilter

Hi David,

That still gives the same error.  From the manpage, it seems that -p is 
needed if using --dport, am I wrong about this?

David Lang wrote:
> just leave out the -p entirely
>
> David Lang
>
> --On Friday, August 25, 2006 01:59:40 PM -0400 Matt Singerman 
> <msingerman@ncemch.org> wrote:
>
>> Hi all,
>>
>> I was wondering, if I wanted to fliter packets on a specific port, can I
>> write a single rule to work on both tcp and udp traffic, or will I have
>> to write one rule for each?
>>
>> Support, for instance, that I want to allow TCP and UDP packets from any
>> host on port 548 to a machine with IP address 192.168.1.4, could I write
>> a rule like:
>>
>> -A FORWARD -s 0/0 -d 141.161.111.203  -p all --dport 548 -j ACCEPT
>>
>> (please note, I am just using port 548 as an example.)
>>
>> Now, I know that this doesn't work, because I tried it :)  I can back 
>> the
>> error:
>>
>> iptables v1.3.5: Unknown arg `--dport'
>>
>> I am guessing that is because "-p all" include ICMP, which doesn't take
>> the --dport argument.  Am I wrong about that?
>>
>> So, to do this, I would have to do two rules:
>>
>> -A FORWARD -s 0/0 -d 141.161.111.203  -p tcp --dport 548 -j ACCEPT
>> -A FORWARD -s 0/0 -d 141.161.111.203  -p udp --dport 548 -j ACCEPT
>>
>> Now, I would prefer not to do this, because in a lot of places, I would
>> have to add a whole lot of rules.  So, I ask, is there a way to comine
>> TCP and UDP into a single rule?
>>
>> Thanks!
>>
>
>
>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: creating one rule for both tcp and udp?
  2006-08-25 17:59 creating one rule for both tcp and udp? Matt Singerman
       [not found] ` <265CD2F3F15DEDF58A73A320@localhost>
@ 2006-08-26 18:47 ` Pascal Hambourg
  1 sibling, 0 replies; 3+ messages in thread
From: Pascal Hambourg @ 2006-08-26 18:47 UTC (permalink / raw)
  To: netfilter

Hello,

Matt Singerman a écrit :
> 
> -A FORWARD -s 0/0 -d 141.161.111.203  -p all --dport 548 -j ACCEPT
> 
> iptables v1.3.5: Unknown arg `--dport'
> 
> I am guessing that is because "-p all" include ICMP, which doesn't take 
> the --dport argument.  Am I wrong about that?

It's a little more complicated than that. It's not that ICMP or other 
protocols don't take the --dport argument. Actually --dport is valid 
only with the "-m tcp" and "-m udp" matches, which in turn are only 
valid with - and implicitly created by - "-p tcp" and "-p udp" respectively.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-08-26 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-25 17:59 creating one rule for both tcp and udp? Matt Singerman
     [not found] ` <265CD2F3F15DEDF58A73A320@localhost>
2006-08-25 18:05   ` Matt Singerman
2006-08-26 18:47 ` Pascal Hambourg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.