Skip to contentSkip to conversation

mport or multiport?

DISCUSSION afshin lamei 3 participants 3 messages Jul 12, 2005

lore
Share & tools
lore
#0 lore raw

Dear all,
"iptables -A INPUT -p tcp -m mport --ports 20:23,80 -j DROP " from patch-o-matic is perfect, but what is that: Source port or Destination port?
I know that with "multiport" i can detrmine source ans dest ports, but it is not so good because it doesn't accept ranges (eg: 20:50).

#1 lore raw
Quoted 3 lines · afshin lamei

"iptables -A INPUT -p tcp -m mport --ports 20:23,80 -j DROP " from patch-o-matic is perfect, but what is that: Source port or Destination port?

Sorry, but RTFM :)

$iptables --version
iptables v1.3.1

$ man iptables
[...]
   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.

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

--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.

--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.

Signature · 2 lines
http://sid.rstack.org/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines

Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!

#2 lore raw
Quoted 4 lines

--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.

There are few daemons which bind to the portnumber they are listening on. BIND could be configured to use a fixed port (e.g. 53) as the source port, and thus would be a possible use for --ports, because most destination ports for dns are 53, _too_.