Linux Netfilter discussions
 help / color / mirror / Atom feed
* multiports
@ 2005-08-04 19:36 Peggy Kam
  2005-08-05  6:34 ` multiports Jan Engelhardt
  0 siblings, 1 reply; 16+ messages in thread
From: Peggy Kam @ 2005-08-04 19:36 UTC (permalink / raw)
  To: netfilter

Hi,

Is it possible to match multiple source and destination ports at the
same time?  It seems to me that it is not possible.  I am using iptables
version 1.2.11 and I have tried the following command:

iptables -A INPUT -p tcp --src 192.168.1.0/255.255.255.0 -m tcp -m
multiport --sports 22,80  --dst 192.168.22.123 -m multiport --dports
22,80 -j ACCEPT

Please correct me if I have the wrong syntax.  Any advice is
appreciated.

Thanks in advance,
Peggy



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

* Re: multiports
  2005-08-04 19:36 multiports Peggy Kam
@ 2005-08-05  6:34 ` Jan Engelhardt
  2005-08-10 20:13   ` Maximum number of ports? Peggy Kam
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Engelhardt @ 2005-08-05  6:34 UTC (permalink / raw)
  To: Peggy Kam; +Cc: netfilter


>Is it possible to match multiple source and destination ports at the
>same time?  It seems to me that it is not possible.  I am using iptables
>version 1.2.11 and I have tried the following command:
>
>iptables -A INPUT -p tcp --src 192.168.1.0/255.255.255.0 -m tcp -m
>multiport --sports 22,80  --dst 192.168.22.123 -m multiport --dports
>22,80 -j ACCEPT

Everything is ANDed, so the following combinations are only possible with your 
rule:

22/22
22/80
80/22
80/80

Probably not what you want, given that most HTTP clients connect from some 
high-random port.

You need to separate rules,
-m multiport --dports 22,80
-m multiport --sports 22,80
to get an OR behavior


Jan Engelhardt
-- 


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

* Maximum number of ports?
  2005-08-05  6:34 ` multiports Jan Engelhardt
@ 2005-08-10 20:13   ` Peggy Kam
  2005-08-11 16:54     ` /dev/rob0
  2005-09-13 22:10     ` Maximum number of rules in iptables? Peggy Kam
  0 siblings, 2 replies; 16+ messages in thread
From: Peggy Kam @ 2005-08-10 20:13 UTC (permalink / raw)
  To: netfilter

Hi,

What is the maximum number of ports that I can define in the iptables?
What is the limitation?

Thanks in advance,
Peggy



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

* Re: Maximum number of ports?
  2005-08-10 20:13   ` Maximum number of ports? Peggy Kam
@ 2005-08-11 16:54     ` /dev/rob0
  2005-09-13 22:10     ` Maximum number of rules in iptables? Peggy Kam
  1 sibling, 0 replies; 16+ messages in thread
From: /dev/rob0 @ 2005-08-11 16:54 UTC (permalink / raw)
  To: netfilter

On Wednesday 2005-August-10 15:13, Peggy Kam wrote:
> What is the maximum number of ports that I can define in the
> iptables? What is the limitation?

Are you asking about the multiport match extension? If so please find 
the following in "man iptables" and post again if you do not understand 
it:

   multiport
       This  module matches a set of source or destination ports.
       Up to 15 ports can be specified.  It can only be used  in
       conjunction with -p tcp or -p udp

That particular limitation only applies to a single multiport command. 
You can have as many of those as you need. Perhaps you're asking about 
the maximum number of rules you can have? I don't know what that limit 
might be (if I was curious I would Google), but I bet it's higher than 
the 64K TCP ports plus the 64K UDP ports.

If you're writing a firewall with that many rules, it is probable that 
you could have done it better and more efficiently using a different 
approach. For instance, default policies of DROP and only ACCEPT the 
port/protocol combinations you need, plus the standard "-m state 
--state RELATED,ESTABLISHED -j ACCEPT" rules.
-- 
    mail to this address is discarded unless "/dev/rob0"
    or "not-spam" is in Subject: header


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

* Maximum number of rules in iptables?
  2005-08-10 20:13   ` Maximum number of ports? Peggy Kam
  2005-08-11 16:54     ` /dev/rob0
@ 2005-09-13 22:10     ` Peggy Kam
  2005-09-14  3:41       ` Edmundo Carmona
  2005-09-15 15:22       ` iptables rules Peggy Kam
  1 sibling, 2 replies; 16+ messages in thread
From: Peggy Kam @ 2005-09-13 22:10 UTC (permalink / raw)
  To: netfilter

Hi,

What is the maximum number of policies I can define in the iptables?  
ie. how much memory is allocated for iptables?

Thanks in advance,
Peggy





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

* Re: Maximum number of rules in iptables?
  2005-09-13 22:10     ` Maximum number of rules in iptables? Peggy Kam
@ 2005-09-14  3:41       ` Edmundo Carmona
  2005-09-14  4:44         ` /dev/rob0
  2005-09-15 15:22       ` iptables rules Peggy Kam
  1 sibling, 1 reply; 16+ messages in thread
From: Edmundo Carmona @ 2005-09-14  3:41 UTC (permalink / raw)
  To: netfilter

that's a NFI for me. A whole bunch.... I've seen red hat scripts that
are way longer than mine. ;-)

On 9/13/05, Peggy Kam <ppkam@n-dsi.com> wrote:
> Hi,
> 
> What is the maximum number of policies I can define in the iptables?
> ie. how much memory is allocated for iptables?
> 
> Thanks in advance,
> Peggy
> 
> 
> 
> 
>


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

* Re: Maximum number of rules in iptables?
  2005-09-14  3:41       ` Edmundo Carmona
@ 2005-09-14  4:44         ` /dev/rob0
       [not found]           ` <65aa6af905091406415094a9ff@mail.gmail.com>
  0 siblings, 1 reply; 16+ messages in thread
From: /dev/rob0 @ 2005-09-14  4:44 UTC (permalink / raw)
  To: netfilter

> On 9/13/05, Peggy Kam <ppkam@n-dsi.com> wrote:
> > What is the maximum number of policies I can define in the
> > iptables? ie. how much memory is allocated for iptables?

I'm sure the answer is in the kernel source code if you need it. This 
forum is more for users than developers. You could try asking on LKML 
or on netfilter-devel, but I don't think you would be well-received 
there unless you showed an effort to find your own answers.

Opinion as a user: it's probably dynamically allocated; more memory is 
used in cases where there are more rules, or where the rules require.

Remembered from Googling: it's not ever likely to be a factor.

Personal experience: an 8MB 80386 is quite capable of handling NAT for 
home and small business broadband connections. I increased the default 
number of connection tracking table (ip_conntrack_max) entries, but 
otherwise had no problem.

On Tuesday 2005-September-13 22:41, Edmundo Carmona wrote:
> that's a NFI for me. A whole bunch.... I've seen red hat scripts that
> are way longer than mine. ;-)

I think it's safe to say that if you're making that many rules, you're 
doing something wrong. :) I said the same thing in this thread to this 
poster over a month ago.

Red Hat iptables rules (that I have seen) are terrible. Do they have 
anyone on staff who understands firewalling? If so, they're not working 
on the firewalls.
-- 
    mail to this address is discarded unless "/dev/rob0"
    or "not-spam" is in Subject: header


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

* Fwd: Maximum number of rules in iptables?
       [not found]           ` <65aa6af905091406415094a9ff@mail.gmail.com>
@ 2005-09-14 13:42             ` Edmundo Carmona
  0 siblings, 0 replies; 16+ messages in thread
From: Edmundo Carmona @ 2005-09-14 13:42 UTC (permalink / raw)
  To: netfilter

Tiem and time again.... I forgot to mail netfilter. I always remember
to do it half a second after I press "send". :-(

---------- Forwarded message ----------
From: Edmundo Carmona <eantoranz@gmail.com>
Date: Sep 14, 2005 9:41 AM
Subject: Re: Maximum number of rules in iptables?
To: /dev/rob0 <rob0@gmx.co.uk>


Well... I guess they happen to be so many rules in those scripts
because they <b>could</b> come out (programatically speaking) more
easily that way.... I'm not saying it's because of that (haven't sat
down to think about a firewall script generator tool)... but it could
play a part.

On 9/14/05, /dev/rob0 <rob0@gmx.co.uk> wrote:
> > On 9/13/05, Peggy Kam <ppkam@n-dsi.com> wrote:
> > > What is the maximum number of policies I can define in the
> > > iptables? ie. how much memory is allocated for iptables?
>
> I'm sure the answer is in the kernel source code if you need it. This
> forum is more for users than developers. You could try asking on LKML
> or on netfilter-devel, but I don't think you would be well-received
> there unless you showed an effort to find your own answers.
>
> Opinion as a user: it's probably dynamically allocated; more memory is
> used in cases where there are more rules, or where the rules require.
>
> Remembered from Googling: it's not ever likely to be a factor.
>
> Personal experience: an 8MB 80386 is quite capable of handling NAT for
> home and small business broadband connections. I increased the default
> number of connection tracking table (ip_conntrack_max) entries, but
> otherwise had no problem.
>
> On Tuesday 2005-September-13 22:41, Edmundo Carmona wrote:
> > that's a NFI for me. A whole bunch.... I've seen red hat scripts that
> > are way longer than mine. ;-)
>
> I think it's safe to say that if you're making that many rules, you're
> doing something wrong. :) I said the same thing in this thread to this
> poster over a month ago.
>
> Red Hat iptables rules (that I have seen) are terrible. Do they have
> anyone on staff who understands firewalling? If so, they're not working
> on the firewalls.
> --
>     mail to this address is discarded unless "/dev/rob0"
>     or "not-spam" is in Subject: header
>
>


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

* iptables rules
  2005-09-13 22:10     ` Maximum number of rules in iptables? Peggy Kam
  2005-09-14  3:41       ` Edmundo Carmona
@ 2005-09-15 15:22       ` Peggy Kam
  2005-09-15 15:26         ` Jörg Harmuth
  2005-09-15 15:33         ` Jörg Harmuth
  1 sibling, 2 replies; 16+ messages in thread
From: Peggy Kam @ 2005-09-15 15:22 UTC (permalink / raw)
  To: netfilter

Hi,

I have defined the following firewall rule in iptables:

iptables -I FORWARD -s 192.168.22.102 -d 192.168.1.112 -p tcp -m tcp -m
multiport --ports 22,23,24,25 -j ACCEPT

why were the packets able to get to 192.168.1.112 on port 22 when the
packets does not even come from ports 22,23,24 or 25?

Thanks in advance,
Peggy





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

* Re: iptables rules
  2005-09-15 15:22       ` iptables rules Peggy Kam
@ 2005-09-15 15:26         ` Jörg Harmuth
  2005-09-15 15:37           ` Peggy Kam
  2005-09-15 15:33         ` Jörg Harmuth
  1 sibling, 1 reply; 16+ messages in thread
From: Jörg Harmuth @ 2005-09-15 15:26 UTC (permalink / raw)
  To: netfilter

Peggy Kam wrote:
> Hi,
> 
> I have defined the following firewall rule in iptables:
> 
> iptables -I FORWARD -s 192.168.22.102 -d 192.168.1.112 -p tcp -m tcp -m
> multiport --ports 22,23,24,25 -j ACCEPT
> 
> why were the packets able to get to 192.168.1.112 on port 22 when the
> packets does not even come from ports 22,23,24 or 25?

man iptables:

--ports [!] port[,port[,port:port...]]
               Match if either the source or destination
               ports are equal to one
               of the given ports.

So, this is expected behaviour, provided that there are no other rules 
in the way.

HTH,

Joerg



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

* Re: iptables rules
  2005-09-15 15:22       ` iptables rules Peggy Kam
  2005-09-15 15:26         ` Jörg Harmuth
@ 2005-09-15 15:33         ` Jörg Harmuth
  1 sibling, 0 replies; 16+ messages in thread
From: Jörg Harmuth @ 2005-09-15 15:33 UTC (permalink / raw)
  To: netfilter

For the sake of completeness :)

Peggy Kam wrote:
> Hi,
> 
> I have defined the following firewall rule in iptables:
> 
> iptables -I FORWARD -s 192.168.22.102 -d 192.168.1.112 -p tcp -m tcp -m
> multiport --ports 22,23,24,25 -j ACCEPT
> 
> why were the packets able to get to 192.168.1.112 on port 22 when the
> packets does not even come from ports 22,23,24 or 25?

man iptables:

multiport

...

       --ports [!] port[,port[,port:port...]]
               Match if either the source or destination
               ports are equal to one
               of the given ports.

So, this is expected behavior, provided that there are no other rules
in the way.

HTH,

Joerg



!DSPAM:43299390313231087616080!


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

* Re: iptables rules
  2005-09-15 15:26         ` Jörg Harmuth
@ 2005-09-15 15:37           ` Peggy Kam
  2005-09-15 16:23             ` Jörg Harmuth
  0 siblings, 1 reply; 16+ messages in thread
From: Peggy Kam @ 2005-09-15 15:37 UTC (permalink / raw)
  To: Jörg Harmuth; +Cc: netfilter

did the manpage gets changed recently?  the iptables manpage that I see
states that:

--port [port[,port]]
        Match if the both the source and destination ports are equal to
        each other and to one of the given ports.


On Thu, 2005-09-15 at 17:26 +0200, Jörg Harmuth wrote:
> Peggy Kam wrote:
> > Hi,
> > 
> > I have defined the following firewall rule in iptables:
> > 
> > iptables -I FORWARD -s 192.168.22.102 -d 192.168.1.112 -p tcp -m tcp -m
> > multiport --ports 22,23,24,25 -j ACCEPT
> > 
> > why were the packets able to get to 192.168.1.112 on port 22 when the
> > packets does not even come from ports 22,23,24 or 25?
> 
> man iptables:
> 
> --ports [!] port[,port[,port:port...]]
>                Match if either the source or destination
>                ports are equal to one
>                of the given ports.
> 
> So, this is expected behaviour, provided that there are no other rules 
> in the way.
> 
> HTH,
> 
> Joerg
> 
> 



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

* Re: iptables rules
  2005-09-15 15:37           ` Peggy Kam
@ 2005-09-15 16:23             ` Jörg Harmuth
  2005-10-21 13:46               ` Realos
  0 siblings, 1 reply; 16+ messages in thread
From: Jörg Harmuth @ 2005-09-15 16:23 UTC (permalink / raw)
  To: netfilter

Peggy Kam wrote:
> did the manpage gets changed recently?  the iptables manpage that I see
> states that:
> 
> --port [port[,port]]
>         Match if the both the source and destination ports are equal to
>         each other and to one of the given ports.


I see. You are referring to -m mport --port*s* (by the way, there is a 
typo or are you referring to another module ?), which is different from 
-m multiport --port*s* port[...] - which I was referring to. Your rule was

... -m multiport --ports 22,23,24,25 -j ACCEPT

So I looked for multiport.

HTH,

Joerg


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

* Re: iptables rules
  2005-09-15 16:23             ` Jörg Harmuth
@ 2005-10-21 13:46               ` Realos
  2005-10-21 16:03                 ` Rob Sterenborg
  2005-10-21 16:19                 ` Jörg Harmuth
  0 siblings, 2 replies; 16+ messages in thread
From: Realos @ 2005-10-21 13:46 UTC (permalink / raw)
  To: netfilter

Jörg Harmuth wanted us to know:


>I see. You are referring to -m mport --port*s* (by the way, there is a 
>typo or are you referring to another module ?), which is different from 
>-m multiport --port*s* port[...] - which I was referring to. Your rule was
>
>... -m multiport --ports 22,23,24,25 -j ACCEPT
>
>So I looked for multiport.

There seems to be an inconsistence between man pages Jörg Harmuth has installed
and of some other people (the original poster and myself at least).

man iptables:

mport
...
 --ports port[,port[,port...]]
	Match if the both the source and destination ports are
	equal to each other and to one  of  the  given
	ports.

multiport
...
	used in conjunction with -p tcp or -p udp.
	rts port[,port[,port...]]
	Match if the both the source and destination ports
	are equal to each other and to one  of  the  given
	ports.

Mar 09, 2002 IPTABLES(8)

BTW, what is the diffence between mport and multiport modules?


-- 
Realos


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

* RE: iptables rules
  2005-10-21 13:46               ` Realos
@ 2005-10-21 16:03                 ` Rob Sterenborg
  2005-10-21 16:19                 ` Jörg Harmuth
  1 sibling, 0 replies; 16+ messages in thread
From: Rob Sterenborg @ 2005-10-21 16:03 UTC (permalink / raw)
  To: netfilter

> There seems to be an inconsistence between man pages Jörg
> Harmuth has installed and of some other people (the original poster
> and myself at least). 
> 
> man iptables:
> 
> mport
> ...
>  --ports port[,port[,port...]]
> 	Match if the both the source and destination ports are
> 	equal to each other and to one  of  the  given
> 	ports.
> 
> multiport
> ...
> 	used in conjunction with -p tcp or -p udp.
> 	rts port[,port[,port...]]
> 	Match if the both the source and destination ports
> 	are equal to each other and to one  of  the  given 	ports.
> 
> Mar 09, 2002 IPTABLES(8)
> 
> BTW, what is the diffence between mport and multiport modules?

Mport is obsoleted according to :
http://www.netfilter.org/projects/patch-o-matic/pom-obsolete.html

Searching the Netfilter site I read that mport was to be combined with
multiport :
http://www.netfilter.org/documentation/conferences/nf-workshop-2004-summ
ary.html (mport TODO: combine with multiport). So, I think this work has
been done.


Gr,
Rob



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

* Re: iptables rules
  2005-10-21 13:46               ` Realos
  2005-10-21 16:03                 ` Rob Sterenborg
@ 2005-10-21 16:19                 ` Jörg Harmuth
  1 sibling, 0 replies; 16+ messages in thread
From: Jörg Harmuth @ 2005-10-21 16:19 UTC (permalink / raw)
  To: netfilter

Realos wrote:
> Jörg Harmuth wanted us to know:
> 
> 
>> I see. You are referring to -m mport --port*s* (by the way, there is a 
>> typo or are you referring to another module ?), which is different from 
>> -m multiport --port*s* port[...] - which I was referring to. Your rule was
>>
>> ... -m multiport --ports 22,23,24,25 -j ACCEPT
>>
>> So I looked for multiport.
> 
> There seems to be an inconsistence between man pages Jörg Harmuth has installed
> and of some other people (the original poster and myself at least).
> 
> man iptables:
> 
> mport
> ...
>  --ports port[,port[,port...]]
> 	Match if the both the source and destination ports are
> 	equal to each other and to one  of  the  given
> 	ports.
> 
> multiport
> ...
> 	used in conjunction with -p tcp or -p udp.
> 	rts port[,port[,port...]]
> 	Match if the both the source and destination ports
> 	are equal to each other and to one  of  the  given
> 	ports.
> 
> Mar 09, 2002 IPTABLES(8)
> 
> BTW, what is the diffence between mport and multiport modules?
> 
> 

Hmm, interesting. I looked again and I see:

man iptables:

  mport
    --ports port[,port[,port...]]
            Match if the both the source and destination ports are
            equal to each other and to one of the given ports.

  multiport
    --ports [!] port[,port[,port:port...]]
            Match if either the source or destination ports are
            equal to one of the given ports.

My iptables is a self compiled 1.3.3 running on Sarge, one box with 
kernel 2.4.31 the other box with kernel 2.6.13.1. May be an iptables 
version issue ?

Have a nice time,

Joerg



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

end of thread, other threads:[~2005-10-21 16:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-04 19:36 multiports Peggy Kam
2005-08-05  6:34 ` multiports Jan Engelhardt
2005-08-10 20:13   ` Maximum number of ports? Peggy Kam
2005-08-11 16:54     ` /dev/rob0
2005-09-13 22:10     ` Maximum number of rules in iptables? Peggy Kam
2005-09-14  3:41       ` Edmundo Carmona
2005-09-14  4:44         ` /dev/rob0
     [not found]           ` <65aa6af905091406415094a9ff@mail.gmail.com>
2005-09-14 13:42             ` Fwd: " Edmundo Carmona
2005-09-15 15:22       ` iptables rules Peggy Kam
2005-09-15 15:26         ` Jörg Harmuth
2005-09-15 15:37           ` Peggy Kam
2005-09-15 16:23             ` Jörg Harmuth
2005-10-21 13:46               ` Realos
2005-10-21 16:03                 ` Rob Sterenborg
2005-10-21 16:19                 ` Jörg Harmuth
2005-09-15 15:33         ` Jörg Harmuth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox