ACPI administration advocacy advocacy advocacy opinion alsa amarok apache apple apt aptitude audio audo authentication automount avi awk bash BIOS boot business cache calendar calibre cdr cdrecord censorship commandline computerscience console convert cron cut database date debian degree design desktop development disk dpkg dvd economics education emacs email europe exim faad ffmpeg file files firefox firewall flash foss freedom ftp fun fuse git gnumeric graphics grep growisofs grub gtkpod hardware hardware html idiocy image imagemagick images installation ip iphone ipod iptables iso itunes ivman kde kernel keyboard knoppix lame laptop latex linux locale lockin longlines m4a microsoft mimetypes minitab mount mp3 mp4 mplayer multimedia music mysql network nfs nfs4 nmap openbox openoffice opinion opinion partition pdf perl php politics postgresql printing privacy programming rant remote rhythmbox rss rsync rxvt scp screengrab screenshot script scripting scsi security sed server shell siteadmin sitenews sitesoftware skype skype slackware sound sox spam spreadsheet ssh statistics subversion sudo svk swap t23 t43 terminal text thinkpad thunderbird time timezone ubuntu udev upgrade usb usbmount users uuid versioncontrol vfat video vnc windows wine wordpress wordprocessing X40 xwindows xwindows youtube
FTP is a difficult protocol to understand (especially when building firewalls). This is an attempt to do so.
The difficulty arises because FTP generally establishes two connections between client and server. The command connection (on which commands are passed back and forth) and the data connection (on which data is transferred - for example the file that you're trying to 'get' or 'put').
FTP servers generally listen on port 21 for connections coming in from unprivileged ports (a port numbered above 1024) on client computers. Commands are sent back on forth on such connections once they have been established.
When data are being passed, such as when a file transfer is being carried out, the ftp software uses different ports on the client and server. The server, by convention, uses port 20. And a different unprivileged port on the client. That anyway is the case in 'standard' mode. When the ftp connection is in 'passive' mode (the choice of standard or passive modes is made by the client), the server sends data from one of its unprivileged ports to an unprivileged port on the client.
The difference between passive and standard modes is that in standard mode, it is the server that sets up the data connection and in passive mode it is the client. That's why it's called passive - because the server passively sits there and waits for the client to establish the data transfer.
Simple sequence for ftp commands in standard mode:
Simple sequence for ftp commands in passive mode:
Any firewall rules have to cope with all this. And that will be a later post.
Some ASCII art to help explain: In 'standard mode': ---------- ---------- | |port >1024 port 21 | | |client |<----------------------->| server | | | | | | |port >1024 port 20 | | | |<----------------------->| | ---------- ---------- In 'passive mode': ---------- ---------- | |port >1024 port 21 | | |client |<----------------------->| server | | | | | | |port >1024 port >1024 | | | |<----------------------->| | ---------- ----------