LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-23-2005, 11:44 AM   #1
mago
Member
 
Registered: Apr 2004
Location: Costa Rica
Distribution: slack current with 2.6.16.18 (still off the hook)
Posts: 284

Rep: Reputation: 33
IPTABLES problem with -m multiport


This might be something really simple but I've been fighting it for 2 days and is starting to drive me crazy.

I'm writing a firewall script and it's over 300 lines already. I want to use the the multiport as follows to save some space and to make the script a bit more manageble but I keep geting an error:
Code:
$IP -A INPUT -p tcp -d x1.x1.x1.x1 -s x2.x2.x2.x2 -m multiport --destination-port 9090:9099 -j ACCEPT
I went through a lot of the documentation in www.netfilter.org and the syntax seems to be right.

Any ideas?


Thanks a bunch in advanced.
 
Old 10-23-2005, 12:31 PM   #2
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
The one module called multiport does not handle the span of ports like you are trying to do from what I know. You want to use the mport module. The multiport can only hande it as a single so one would have to use it like this.
Code:
$IP -A INPUT -p tcp -d x1.x1.x1.x1 -s x2.x2.x2.x2 -m multiport --destination-port 9090,9091,9092,9093,9094,9095,9096,9097,9098,9099 -j ACCEPT
Using mport you can do it this way.
Code:
$IP -A INPUT -p tcp -d x1.x1.x1.x1 -s x2.x2.x2.x2 -m mport --destination-port 9090:9099 -j ACCEPT
And if wish to go farther you can do it as this for addtional ports.
Code:
$IP -A INPUT -p tcp -d x1.x1.x1.x1 -s x2.x2.x2.x2 -m mport --destination-port 22,6000:6003,8529,9090:9099 -j ACCEPT
Hope this helps.
Brian1
 
Old 10-23-2005, 02:47 PM   #3
mago
Member
 
Registered: Apr 2004
Location: Costa Rica
Distribution: slack current with 2.6.16.18 (still off the hook)
Posts: 284

Original Poster
Rep: Reputation: 33
Thanks a lot for the quick answer, my fault I assume that -m multiport and -mport where pretty much the same.
 
Old 10-24-2005, 05:03 PM   #4
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 441

Rep: Reputation: 141Reputation: 141
Quote:
Originally posted by Brian1
The one module called multiport does not handle the span of ports like you are trying to do from what I know. You want to use the mport module. The multiport can only hande it as a single so one would have to use it like this.
Code:
$IP -A INPUT -p tcp -d x1.x1.x1.x1 -s x2.x2.x2.x2 -m multiport --destination-port 9090,9091,9092,9093,9094,9095,9096,9097,9098,9099 -j ACCEPT
Using mport you can do it this way.
Code:
$IP -A INPUT -p tcp -d x1.x1.x1.x1 -s x2.x2.x2.x2 -m mport --destination-port 9090:9099 -j ACCEPT
And if wish to go farther you can do it as this for addtional ports.
Code:
$IP -A INPUT -p tcp -d x1.x1.x1.x1 -s x2.x2.x2.x2 -m mport --destination-port 22,6000:6003,8529,9090:9099 -j ACCEPT
Hope this helps.
Brian1
I may be wrong by my iptables manpage mentions the exact opposite
Code:
   mport
       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.

       --destination-ports port[,port[,port...]]
              Match if the destination port is one of the  given  ports.   The
              flag --dports is a convenient alias for this option.

   multiport
       This module matches a set of source or destination  ports.   Up  to  15
       ports  can be specified.  A port range (port:port) counts as two ports.
       It can only be used in conjunction with -p tcp or -p udp.

       --destination-ports [!] port[,port[,port:port...]]
              Match  if  the  destination port is one of the given ports.  The
              flag --dports is a convenient alias for this option.
Also, for a simple span of ports you don't need extensions
You can do the following:
Code:
$IP -A INPUT -p tcp -d x1.x1.x1.x1 -s x2.x2.x2.x2 --dport 9090:9099 -j ACCEPT
 
Old 10-26-2005, 10:10 PM   #5
mago
Member
 
Registered: Apr 2004
Location: Costa Rica
Distribution: slack current with 2.6.16.18 (still off the hook)
Posts: 284

Original Poster
Rep: Reputation: 33
-m multiport,mport none of them work for me, What am I doing wrong?

Ok I guess I went totally dumb but I just cant make it work

Here is an example of what I'm trying to do:
Code:
$IP -A INPUT -p tcp -m mport -s $WWW -d $POKER2  --dports 7327,9090:9099 -j ACCEPT
When I run it I just get this:

Quote:
Couldn't load match `mport':/usr/lib/iptables/libipt_mport.so: cannot open shared object file: No such file or directory

I'm running iptables 1.3.1 so I don't belive I need to patch-o-matic my install do I?

Last edited by mago; 10-26-2005 at 10:28 PM.
 
Old 10-27-2005, 08:14 AM   #6
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 441

Rep: Reputation: 141Reputation: 141
Re: -m multiport,mport none of them work for me, What am I doing wrong?

Quote:
Originally posted by mago
Ok I guess I went totally dumb but I just cant make it work

Here is an example of what I'm trying to do:
Code:
$IP -A INPUT -p tcp -m mport -s $WWW -d $POKER2  --dports 7327,9090:9099 -j ACCEPT
When I run it I just get this:




I'm running iptables 1.3.1 so I don't belive I need to patch-o-matic my install do I?
This means that you don't have the module for iptables since it can't load the .so library.
If you run "man iptables" you will see that you need the "multiport" and NOT the "mport" module (at least according to my
manpage)

( Also mport is deprecated according to http://netfilter.org/projects/patch-...obsolete-mport )

so try
Code:
$IP -A INPUT -p tcp -m multiport -s $WWW -d $POKER2  --dports 7327,9090:9099 -j ACCEPT
if not then try
Code:
$IP -A INPUT -p tcp -m multiport -s $WWW -d $POKER2  --dport 7327 -j ACCEPT
$IP -A INPUT -p tcp -m multiport -s $WWW -d $POKER2  --dport 9090:9099 -j ACCEPT
 
  


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
moxa multiport driver for 2.6.x?! silvercloud Linux - Hardware 0 09-24-2005 02:04 AM
PC-COM Multiport Serial card king_nothingzzz Linux - Hardware 18 05-27-2005 08:15 PM
Multiport serial card and kernel 2.6 cits Linux - Hardware 3 03-17-2005 08:41 AM
Multiport Serial Card question FuriousGeorge Linux - Hardware 4 06-22-2004 07:59 AM
Multiport serial card for RAS Server uthlekan Linux - Networking 2 07-12-2003 10:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 02:42 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