LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-26-2009, 11:47 AM   #1
ichrispa
Member
 
Registered: Mar 2005
Location: Dresden, Germany
Distribution: OpenSuse 11.2/3, Debian 5.0 , Debian 1.3.1, OpenBSD
Posts: 277

Rep: Reputation: 32
nf_conntrack/nf_conntrack_ftp - what is the difference?


Hello everyone,

first off, this is not a "this doesn't work, help me fix it"-thread. It works. My question is: why?

In detail: I wanted to set up an ftp server (vsftpd, port 21 for ftp-control, 40000 to 40100 for passive ftp). With nf_conntrack loaded, I modified my iptables as follows:

Code:
iptables -I INPUT -p tcp --dport 21 -j ACCEPT
iptables -I INPUT -p tcp -m mutliport --dports 40000:40100 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -I OUTPUT -p tcp -m mutliport --sports 40000:40100 -m state --state RELATED,ESTABLISHED -j ACCEPT

All chain policies are set to DROP.

Now, when I connect to port 21 (using an ftp client and passive mode) from a different host, /proc/net/nf_conntrack confirms that the connection is established:

Code:
ipv4     2 tcp      6 431991 ESTABLISHED src=10.0.52.1 dst=10.0.62.100 sport=57359 dport=21 packets=9 bytes=508 src=10.0.62.100 dst=10.0.52.1 sport=21 dport=57359 packets=6 bytes=465 [ASSURED] mark=0 secmark=0 use=1
However, when i try to get data/listings, the connection hangs. netstat confirms a passive port on the server is open, but the client can't connect. Why can't he connect? Shouldn't this connection be considered RELATED?

The problem is fixed entirely when i load the nf_conntrack_ftp module. The only iptables rule needed is the --dport 21 rule in the INPUT chain.

What does the nf_conntrack_ftp module do differently then applying similar rules than the ones I issued to iptables above?

Thanks in advance,

Chris
 
Old 12-26-2009, 12:22 PM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
I cannot tell you precisely what the ftp-conntrack module does differently than the regular conntrack module (I suppose it monitors the control connection?? To see what ports will be used for the data??); however I can tell you this:

1) with active FTP, the control connection on port-21 qualifies as ESTABLISHED, RELATED, and so does the data connection on whatever ports you run that on.

2) With passive ftp, the control connection on p-21 is still ESTABLISHED, RELATED, but the data connection is not; it is neither ESTABLISHED nor RELATED, or the transfer/connection will hang.

Something else:

1) Maybe you just made a typo up there in your post, but in your rules, you write "mutliport" instead of "multiport" -- in real situation, it might cause problem

Sasha
 
Old 12-26-2009, 03:34 PM   #3
ichrispa
Member
 
Registered: Mar 2005
Location: Dresden, Germany
Distribution: OpenSuse 11.2/3, Debian 5.0 , Debian 1.3.1, OpenBSD
Posts: 277

Original Poster
Rep: Reputation: 32
thx GrapefruiTgirl, that was a typo when i wrote the post.

I'll simply accept the fact that the nf_conntrack_ftp module resolved my problem as I expected for now. I'll post more details if I ever find spare time to read the sources of the module
 
Old 09-26-2011, 05:38 AM   #4
Chenchu
Member
 
Registered: Nov 2009
Location: Mars
Distribution: CentOS
Posts: 50

Rep: Reputation: 20
I also got into this problem today, and the reason you need nf_conntrack_ftp module loaded as well is because the nf_conntrack module USES the nf_conntrack_ftp module to track ftp connections. it's like parent and son relation, nf_conntrack is a general tracking module, and if you want it to track ftp as well you need to load another module which is USED BY the nf_conntrack.

you simply can see this with lsmod.
 
  


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
shell script to find the difference betwwn two file and place the difference to other kittunot4u Linux - General 3 07-19-2010 04:26 AM
where is the file location of iptable rules (nf_conntrack) jmbreija Linux - Newbie 1 12-09-2009 08:47 PM
How can I disable the nf_conntrack until after I boot? guserx Linux - Newbie 3 09-03-2009 01:50 PM
How specify kernel module options for 2.6.25 (nf_conntrack_ftp) ocgltd Linux - Networking 0 09-13-2008 05:21 PM
Increase nf_conntrack value c00kie Linux - Security 2 07-11-2007 03:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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