From: "jherschel" Subject: PASV rules opening up my high-ports! Date: Mon, 26 May 2003 14:35:38 -0400 Sender: netfilter-admin@lists.netfilter.org Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0054_01C32394.136CB850" Return-path: Errors-To: netfilter-admin@lists.netfilter.org List-Help: List-Post: List-Subscribe: , List-Id: List-Unsubscribe: , List-Archive: To: netfilter@lists.netfilter.org This is a multi-part message in MIME format. ------=_NextPart_000_0054_01C32394.136CB850 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Howdy, Thanks in advance for reading this, if this is a common issue, I apologize = =96 but could you point me to a searchable archive so I don=92t bug this list w= ith previously asked questions? Anyways =96 here goes =85 I=92ve got rules for FTP inbound/outbound for both PORT and PASV connection= s. I=92m also running MySQL, which defaults to port 3306. If FTP PASV rules are enabled, either as a server or client, it seems all my high ports are open to be connected to. I=92ve tried enforcing state, but I end up either breaking the rule so that FTP doesn=92t work, or I end up opening the high-ports again. Is there a way to fix this by developing a better rule? Or should I limit my PASV ports to a range that does not overlap with other services? Here are the related rules =85 (the PASV rules are commented out) # # General rules # modprobe ip_tables modprobe ip_conntrack modprobe ip_conntrack_ftp ################################################################# # Kernel configuration section and cleansing of the filter, nat,# # and mangle tables # ################################################################# echo -n $"clearing old rules from tables:" $IPTABLES -F && \ $IPTABLES -t filter -F INPUT && \ $IPTABLES -t filter -F FORWARD && \ # commands to zero chain counters - needed on restart $IPTABLES -X $IPTABLES -t filter -Z && \ success $"clearing old rules from tables" || \ failure $"clearing old rules from tables" echo # set all filtering to DROP as default echo -n $"setting default rules to DROP: " # used to be IPTABLES -t filter -P ... $IPTABLES -P INPUT DROP && \ $IPTABLES -P FORWARD DROP && \ $IPTABLES -P OUTPUT DROP && \ success $"setting default rules to DROP" || \ failure $"setting default rules to DROP" echo # # FTP RULES # if [[ $FTP_client =3D=3D 1 ]] ; then echo -n $"adding FTP client rules: " # Outgoing Request $IPTABLES -A INPUT -i $IFACE -p tcp \ -s any/0 --sport 21 \ -d $LOCAL_IP --dport 1024: \ -m state --state ESTABLISHED \ -j ACCEPT &&\ $IPTABLES -A OUTPUT -o $IFACE -p tcp \ -s $LOCAL_IP --sport 1024: \ -d any/0 --dport 21 \ -m state --state NEW,ESTABLISHED \ -j ACCEPT &&\ # PORT FTP Connections $IPTABLES -A INPUT -i $IFACE -p tcp \ -s any/0 --sport 20 \ -d $LOCAL_IP --dport 1024: \ -m state --state ESTABLISHED,RELATED \ -j ACCEPT &&\ $IPTABLES -A OUTPUT -o $IFACE -p tcp \ -s $LOCAL_IP --sport 1024: \ -d any/0 --dport 20 \ -m state --state ESTABLISHED \ -j ACCEPT &&\ # PASV FTP Connections # $IPTABLES -A INPUT -i $IFACE -p tcp \ # -s any/0 --sport 1024: \ # -d $LOCAL_IP --dport 1024: \ # -m state --state ESTABLISHED \ # -j ACCEPT &&\ # $IPTABLES -A OUTPUT -o $IFACE -p tcp \ # -s $LOCAL_IP --sport 1024: \ # -d any/0 --dport 1024: \ # -m state --state ESTABLISHED,RELATED \ # -j ACCEPT &&\ success $"adding FTP client rules" || \ failure $"adding FTP client rules" echo fi Thanks again, James ------=_NextPart_000_0054_01C32394.136CB850 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Howdy,

 

Thanks in advance for reading this, if this is a common issue, I = apologize – but could you point me to a searchable archive so I don’t = bug this list with previously asked questions?

 

Anyways – here goes = …

 

I’ve got rules for FTP inbound/outbound for both PORT and = PASV connections.  I’m = also running MySQL, which defaults to port 3306.

 

If FTP PASV rules are enabled, either as a server or client, it = seems all my high ports are open to be connected to.  I’ve tried enforcing state, but I end up either = breaking the rule so that FTP doesn’t work, or I end up opening the high-ports = again.

 

Is there a way to fix this by developing a better rule? Or should = I limit my PASV ports to a range that does not overlap with other = services?

 

Here are the related rules … (the PASV rules are commented = out)

 

#

# General rules

#

modprobe ip_tables

modprobe ip_conntrack

modprobe ip_conntrack_ftp

 

#################################################################<= o:p>

# Kernel configuration section and cleansing of the filter, = nat,#

# and mangle tables           &n= bsp;           &nb= sp;           &nbs= p;         #

#################################################################<= o:p>

echo -n $"clearing old rules from = tables:"

 

$IPTABLES -F && \

$IPTABLES -t filter -F INPUT && = \

$IPTABLES -t filter -F FORWARD && = \

# commands to zero chain counters - needed on = restart

$IPTABLES -X

$IPTABLES -t filter -Z && = \

 

success $"clearing old rules from tables" || = \

failure $"clearing old rules from = tables"

echo

 

# set all filtering to DROP as = default

echo -n $"setting default rules to DROP: = "

 

# used to be IPTABLES -t filter -P = ...

 

$IPTABLES -P INPUT DROP && = \

$IPTABLES -P FORWARD DROP && = \

$IPTABLES -P OUTPUT DROP  && \

 

success $"setting default rules to DROP" || = \

failure $"setting default rules to = DROP"

echo

 

#

# FTP RULES

#

 

if [[ $FTP_client =3D=3D 1 ]] ; = then

        echo -n = $"adding FTP client rules: "

 

        # Outgoing = Request

 

        $IPTABLES -A = INPUT -i $IFACE -p tcp \

           &n= bsp;            -s any/0 --sport 21 \

           &n= bsp;            -d $LOCAL_IP --dport 1024: \

              &n= bsp;         -m state --state ESTABLISHED \

           &n= bsp;            -j ACCEPT &&\

        $IPTABLES -A = OUTPUT -o $IFACE -p tcp \

           &n= bsp;            -s $LOCAL_IP --sport 1024: \

           &n= bsp;            -d any/0 --dport 21 \

           &n= bsp;            -m state --state NEW,ESTABLISHED = \

           &n= bsp;            -j ACCEPT &&\

 

        # PORT FTP = Connections

 

        $IPTABLES -A = INPUT -i $IFACE -p tcp \

           &n= bsp;            -s any/0 --sport 20 \

           &n= bsp;            -d $LOCAL_IP --dport 1024: \

           &n= bsp;            -m state --state ESTABLISHED,RELATED = \

           &n= bsp;            -j ACCEPT &&\

        $IPTABLES -A = OUTPUT -o $IFACE -p tcp \

           &n= bsp;            -s $LOCAL_IP --sport 1024: \

           &n= bsp;            -d any/0 --dport 20 \

           &n= bsp;            -m state --state ESTABLISHED = \

           &n= bsp;            -j ACCEPT &&\

 

        # PASV FTP = Connections

 

#       $IPTABLES -A INPUT -i $IFACE -p tcp = \

#           &n= bsp;           -s any/0 --sport 1024: \

#           &n= bsp;           -d $LOCAL_IP --dport 1024: \

#           &n= bsp;           -m state --state ESTABLISHED = \

#           &n= bsp;           -j ACCEPT &&\

#       $IPTABLES -A OUTPUT -o $IFACE -p tcp = \

#           &n= bsp;           -s $LOCAL_IP --sport 1024: \

#           &n= bsp;           -d any/0 --dport 1024: \

#           &n= bsp;           -m state --state ESTABLISHED,RELATED = \

#           &n= bsp;          -j ACCEPT &&\

 

        success = $"adding FTP client rules" || \

        failure = $"adding FTP client rules"

        = echo

fi

 

Thanks again,

 

James

------=_NextPart_000_0054_01C32394.136CB850--