Skip to contentSkip to conversation

how can i filter for a range of ports?

LARTC Adam Schrader 4 participants 4 messages Apr 14, 2003 – Apr 16, 2003

lore
Share & tools
lore
#0 lore raw

how can i filter for a range of ports? I have seen people use 1024:32000 when saying from port 1024 to 32000 but tc doesnt accept this? can somebody tell me how i can do this? -thanks

---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

#1 lore raw
Quoted 3 lines · Adam Schrader

how can i filter for a range of ports? I have seen people use 1024:32000 when saying from port 1024 to 32000 but tc doesnt accept this? can somebody tell me how i can do this? -thanks

You cannot easyly do this, but there is a solution:
You can use a mask != 0xffff for ports.
Very probably you must use several lines to cover whole range. So, as an example, for 1024 -> 1279 (1024 + 256 - 1) you can use match tcp sport 1024 0xff00.

For 4096 -> 65535 you can use:
match tcp sport 4096 0xf000

I think you get the idea.

Or you can just use marking.

Quoted 7 lines

---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

---
Catalin(ux) BOIE
[email protected]
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#2 lore raw
In reply to Adam Schrader
Quoted 1 line
Quoted 1 line

"AS" = Adam Schrader <[email protected]> writes:

AS> how can i filter for a range of ports? I have seen people use AS> 1024:32000 when saying from port 1024 to 32000 but tc doesnt AS> accept this? can somebody tell me how i can do this? -thanks

iptables -A INPUT -p tcp --dport 1024:65535 -j ACCEPT

Should do what you want. iptables is very limited in defining ranges, multiple hosts and similar ranges compares to ipfw2. I hope this will change sometime in the future since it would highly simplify the definitions of large rulesets.

/ahnberg.

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#3 lore raw
In reply to Adam Schrader
Quoted 6 lines · Mattias Ahnberg
Quoted 1 line
Quoted 1 line

"AS" = Adam Schrader <[email protected]> writes:

AS> how can i filter for a range of ports? I have seen people use AS> 1024:32000 when saying from port 1024 to 32000 but tc doesnt AS> accept this? can somebody tell me how i can do this? -thanks

Quoted 6 lines

iptables -A INPUT -p tcp --dport 1024:65535 -j ACCEPT

Should do what you want. iptables is very limited in defining ranges, multiple hosts and similar ranges compares to ipfw2. I hope this will change sometime in the future since it would highly simplify the definitions of large rulesets.

There is an iptables patch to do this :
http://www.netfilter.org/documentation/pomlist/pom-base.html#mport

Example :
iptables -A FORWARD -p tcp -m mport --ports 23:42,65

Stef

Signature · 8 lines
[email protected]
 "Using Linux as bandwidth manager"
     http://www.docum.org/
     #lartc @ irc.oftc.net

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/