Allow active and passive FTP connections
Hi all
Today I upgraded the Linux kernel to 2.6.7.
Applied following patches of the patch-o-matic-ng-20040302:
init_conntrack-optimize NETMAP SAME TTL connlimit fuzzy iprange ipv4options mport raw CLASSIFY addrtype childlevel owner-socketlookup
Compiled in all netfiter options to the kernel.
After the server is booted with the new kernel, I recompiled and reinstalled the iptables.
But my problem is still the same. The “-m state --state ESTABLISHED” works well, but the “-m state --state RELATED” does not work at all for FTP data connections. What have I missed?
Is there an alternative method to know that a particular --syn connection a part of an existing FTP connection without using RELATED?
Any ideas please?
Sagara
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
Quoted 9 lines · Sagara Wijetunga
Today I upgraded the Linux kernel to 2.6.7.
Applied following patches of the patch-o-matic-ng-20040302:
init_conntrack-optimize NETMAP SAME TTL connlimit fuzzy iprange ipv4options mport raw CLASSIFY addrtype childlevel owner-socketlookupCompiled in all netfiter options to the kernel.
Could you post the output of
grep IP_NF_ .config
running it in the source tree of linux-2.6.7?
Quoted 7 lines
After the server is booted with the new kernel, I
recompiled and reinstalled the iptables.But my problem is still the same. The “-m state --state ESTABLISHED” works well, but the “-m state --state RELATED” does not work at all for FTP data connections. What have I missed?
You should post the complete list of your rules in all of the tables.
There is something definitely wrong in your configuration.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
Quoted 8 lines · --- Jozsef Kadlecsik
Quoted 6 lines · Sagara Wijetunga
Today I upgraded the Linux kernel to 2.6.7.
Applied following patches of the
patch-o-matic-ng-20040302:
init_conntrack-optimize NETMAP SAME TTL connlimit
fuzzy iprange ipv4options mport raw CLASSIFY
Quoted 9 lines
addrtype
Quoted 3 lines
childlevel owner-socketlookup
Compiled in all netfiter options to the kernel.
Could you post the output of
grep
IP_NF_.config
cd /usr/src/linux-2.6.7
grep IP_NF_ .config
CONFIG_IP_NF_CONNTRACK=yCONFIG_IP_NF_FTP=yCONFIG_IP_NF_IRC=yCONFIG_IP_NF_TFTP=y
# CONFIG_IP_NF_AMANDA is not setCONFIG_IP_NF_QUEUE=yCONFIG_IP_NF_IPTABLES=yCONFIG_IP_NF_MATCH_LIMIT=yCONFIG_IP_NF_MATCH_IPRANGE=yCONFIG_IP_NF_MATCH_MAC=yCONFIG_IP_NF_MATCH_PKTTYPE=yCONFIG_IP_NF_MATCH_MARK=yCONFIG_IP_NF_MATCH_MULTIPORT=yCONFIG_IP_NF_MATCH_TOS=yCONFIG_IP_NF_MATCH_RECENT=yCONFIG_IP_NF_MATCH_ECN=yCONFIG_IP_NF_MATCH_DSCP=yCONFIG_IP_NF_MATCH_AH_ESP=yCONFIG_IP_NF_MATCH_LENGTH=yCONFIG_IP_NF_MATCH_TTL=yCONFIG_IP_NF_MATCH_TCPMSS=yCONFIG_IP_NF_MATCH_HELPER=yCONFIG_IP_NF_MATCH_STATE=yCONFIG_IP_NF_MATCH_CONNTRACK=yCONFIG_IP_NF_MATCH_OWNER=yCONFIG_IP_NF_FILTER=yCONFIG_IP_NF_TARGET_REJECT=yCONFIG_IP_NF_NAT=yCONFIG_IP_NF_NAT_NEEDED=yCONFIG_IP_NF_TARGET_MASQUERADE=yCONFIG_IP_NF_TARGET_REDIRECT=yCONFIG_IP_NF_TARGET_NETMAP=yCONFIG_IP_NF_TARGET_SAME=y
# CONFIG_IP_NF_NAT_LOCAL is not set
# CONFIG_IP_NF_NAT_SNMP_BASIC is not setCONFIG_IP_NF_NAT_IRC=yCONFIG_IP_NF_NAT_FTP=yCONFIG_IP_NF_NAT_TFTP=yCONFIG_IP_NF_MANGLE=yCONFIG_IP_NF_TARGET_TOS=yCONFIG_IP_NF_TARGET_ECN=yCONFIG_IP_NF_TARGET_DSCP=yCONFIG_IP_NF_TARGET_MARK=yCONFIG_IP_NF_TARGET_CLASSIFY=yCONFIG_IP_NF_TARGET_LOG=yCONFIG_IP_NF_TARGET_ULOG=yCONFIG_IP_NF_TARGET_TCPMSS=yCONFIG_IP_NF_ARPTABLES=yCONFIG_IP_NF_ARPFILTER=yCONFIG_IP_NF_ARP_MANGLE=yCONFIG_IP_NF_TARGET_NOTRACK=yCONFIG_IP_NF_RAW=yCONFIG_IP_NF_TARGET_TTL=yCONFIG_IP_NF_MATCH_CONNLIMIT=yCONFIG_IP_NF_MATCH_FUZZY=yCONFIG_IP_NF_MATCH_IPV4OPTIONS=yCONFIG_IP_NF_MATCH_MPORT=yCONFIG_IP_NF_MATCH_ADDRTYPE=y
The iptables-1.2.10 was compiled and installed as
follows:
CC="gcc -D__user= "
export CC
make BINDIR=/sbin LIBDIR=/lib \
MANDIR=/usr/share/man KERNEL_DIR=/usr/src/linux-2.6.7
Quoted 1 line
& iptables-make.log
make BINDIR=/sbin LIBDIR=/lib \
MANDIR=/usr/share/man install
KERNEL_DIR=/usr/src/linux-2.6.7 >&
iptables-install.log
/sbin/ldconfig
Quoted 11 lines
Quoted 7 lines
After the server is booted with the new kernel, I
recompiled and reinstalled the iptables.But my problem is still the same. The “-m state --state ESTABLISHED” works well, but the “-m state --state RELATED” does not work at all for FTP data connections. What have I missed?
You should post the complete list of your rules in all of the tables.
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -A INPUT -m state --state INVALID -j
DROP
/sbin/iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP /sbin/iptables -A INPUT -p tcp --tcp-flags ALL FIN
-j DROP
/sbin/iptables -A INPUT -m state --state
ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 21 --tcp-flags ACK,PSH,URGP ACK,PSH -j DROP /sbin/iptables -A INPUT -p tcp --tcp-flags FIN,ACK FIN,ACK -j DROP /sbin/iptables -A INPUT -p tcp --tcp-flags RST,ACK
RST,ACK -j DROP
/sbin/iptables -A INPUT -p tcp --dport 21 --syn -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 22 --syn -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 25 --syn -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 53 --syn -j ACCEPT /sbin/iptables -A INPUT -p udp --dport 53 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 80 --syn -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 110 --syn -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 143 --syn -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 443 --syn -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 465 --syn -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 993 --syn -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 995 --syn -j
ACCEPT
/sbin/iptables -A INPUT -m limit --limit 1/s -j LOG
--log-prefix 'INPUT PKT DROPPED: '
/sbin/iptables -A OUTPUT -m state --state INVALID -j DROP /sbin/iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT /sbin/iptables -A OUTPUT -p tcp --dport 53 --syn -j ACCEPT /sbin/iptables -A OUTPUT -p udp --dport 53 -j ACCEPT /sbin/iptables -A OUTPUT -p tcp --dport 25 --syn -j
ACCEPT
/sbin/iptables -A OUTPUT -m limit --limit 1/s -j LOG
--log-prefix 'OUTPUT PKT DROPPED: '
Please let me know if you require any further info in this regard.
Sagara
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
Quoted 13 lines · Sagara Wijetunga
Quoted 13 lines
Quoted 6 lines
Today I upgraded the Linux kernel to 2.6.7.
Applied following patches of the
patch-o-matic-ng-20040302:
init_conntrack-optimize NETMAP SAME TTL connlimit
fuzzy iprange ipv4options mport raw CLASSIFYaddrtype
Quoted 3 lines
childlevel owner-socketlookup
Compiled in all netfiter options to the kernel.
Could you post the output of
Quoted 7 lines
Quoted 2 lines
grep
IP_NF_.configcd
/usr/src/linux-2.6.7
grepIP_NF_.config
CONFIG_IP_NF_CONNTRACK=yCONFIG_IP_NF_FTP=y
OK.
Quoted 1 line
The iptables-1.2.10 was compiled and installed as
Are you sure, you run the kernel indicated?
How did you compile iptables-1.2.10? There was a bug introduced in linux-2.6.7, which prevented anyone to compile the iptables source using linux-2.6.7.
Quoted 6 lines
Quoted 3 lines
You should post the complete list of your rules in all of the tables.
/sbin/iptables-P INPUT DROP
/sbin/iptables-P FORWARD DROP
/sbin/iptables-P OUTPUT DROP
What about the nat/mangle/raw tables?
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
Quoted 2 lines · --- Jozsef Kadlecsik
Are you sure, you run the kernel indicated?
uname -a
Linux svr1.myDomain 2.6.7 ...
Quoted 6 lines
How did you compile iptables-1.2.10? There was a bug introduced in
linux-2.6.7, which prevented anyone to compile the iptables source
using linux-2.6.7.
I exported the variable CC before I compile iptables as follows:
CC="gcc -D__user= "
export CC
make BINDIR=/sbin LIBDIR=/lib \
MANDIR=/usr/share/man KERNEL_DIR=/usr/src/linux-2.6.7
Quoted 1 line
& iptables-make.log
make BINDIR=/sbin LIBDIR=/lib \
MANDIR=/usr/share/man install
KERNEL_DIR=/usr/src/linux-2.6.7 >&
iptables-install.log
Anyway, my problem is nothing to do with Linux kernel 2.6.7. The RELATED did not work on kernel 2.6.5 and iptables 1.2.9. That's why I upgraded the kernel and the iptables.
Quoted 10 lines
Quoted 1 line
Quoted 1 line
You should post the complete list of your rules
in
Quoted 5 lines
Quoted 2 lines
all of the tables.
/sbin/iptables-P INPUT DROP
/sbin/iptables-P FORWARD DROP
/sbin/iptables-P OUTPUT DROPWhat about the nat/mangle/raw tables?
I do not use NAT. It does not operate as a router. Therefore, no IP forwarding. It's not connected to any office LAN. Access is only thru the eth0.
I'm not sure about mangle and raw tables. My intention is to allow access only to the services I offer.
Do I have to use mangle and raw tables?
Could you kindly write for me a complete iptables firewall allowing access ONLY to the FTP and ssh? I know this is a crazy request. But I can implement it on my server and test. So our test firewall should be able to accept active as well as passive FTP client connections for file upload and download and ssh access for me to manipulate the server.
Kind regards
Sagara
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail