Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
My FTP users can login but can not send/receive data when I use the below iptables configuration.
Can someone make any recommendation to resolve the FTP connection issue.
Thanks for your help.
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [131962:7397220]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
-A RH-Firewall-1-INPUT -p ipv6-crypt -j ACCEPT
-A RH-Firewall-1-INPUT -p ipv6-auth -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
Are you loading the correct connection tracking modules in your /etc/sysconfig/iptables-config file? Something like this:-
IPTABLES_MODULES="ip_conntrack_ftp nf_conntrack_netbios_ns"
My FTP users can login but can not send/receive data when I use the below iptables configuration.
Can someone make any recommendation to resolve the FTP connection issue.
Thanks for your help.
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [131962:7397220]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
-A RH-Firewall-1-INPUT -p ipv6-crypt -j ACCEPT
-A RH-Firewall-1-INPUT -p ipv6-auth -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
The rule you have for port 20 is not necessary (only port 21 is). The RELATED,ESTABLISHED rule will pick-up the client's data connection, which won't happen on port 20 anyway (not in passive mode). Your issue is most likely caused by not having FTP connection tracking support in your kernel, or not having the FTP connection tracking module loaded. Try doing a:
Code:
modprobe ip_conntrack_ftp
BTW, I'm moving this to Networking, as it isn't a security issue.
I was reading on the net and I see suggestions for opening ports greater than 1024.
That definitely made sense like 10 years ago when we didn't have connection tracking. Today, such a rule would be completely insane. Connection tracking makes this sort of security nightmare totally unnecessary. As has already been said, for FTP services you only need port 21 open.
Quote:
Do you think adding this iptables line will resolve this FTP connection issue?
No, at least not without FTP connection tracking. See, for Netfilter to know that the state of those FTP data connection packets is RELATED or ESTABLISHED it would need to have FTP connection tracking support enabled in the first place - which you apparently don't have AFAICT. Note that if this rule would work, it would be redundant, as it would imply that your current RELATED,ESTABLISHED rule was working originally. You won't need to make any additional RELATED,ESTABLISHED rules once you've got FTP connection tracking working.
You could remove the state matches from the rule and do it like we're in 1998 like:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.