Ftp: 425 Unable to build data connection

October 16, 2009    |   Posted by admin   |    Category: Linux Administration

Error Message:

LIST
425 Unable to build data connection: Connection timed out
PASV
227 Entering Passive Mode (xx,xx,xx,xx,xx,xxx).
connecting data channel to xx.xxx.xx.xxx:54963

The above error message is received while you Ftp to an account successfully but it does not list the files and directories within it. The reason for the error message is, the kernel modules that are required for Ftp “i.e. to keep track of every Ftp connection and carry out the data transfer of it on another port” is not loaded.

The modules are “ip_conntrack” and “ip_conntrack_ftp” which has to be loaded using the ‘modprobe’ command.

SSH to your server as user root and execute the following commands:

# /sbin/modprobe ip_conntrack
# /sbin/modprobe ip_conntrack_ftp

To verify if the modules are loaded properly, execute

# lsmod | grep ftp

This should list the modules you just loaded. Once they appear, ftp should list the files/directories on successful login.

Comments Off on Ftp: 425 Unable to build data connection

Howto: deny/allow IP using iptables

October 16, 2009    |   Posted by admin   |    Category: Linux Administration

How to block an IP using iptables?

iptables -A INPUT -s xx.xx.xx.xx -j DROP

How to block an IP for a specific port:

iptables -A INPUT -p tcp -s xx.xx.xx.xx --dport PORT -j DROP

How to allow access to an IP?

iptables -A INPUT -s xx.xx.xx.xx -j ACCEPT

How to allow access to an IP to a specific port using iptables?

iptables -A INPUT -p tcp -s xx.xx.xx.xx --dport PORT -j ACCEPT

where, xx.xx.xx.xx is the remote IP address and PORT is the port number you wish to allow/deny access to.

How to block a scanner on your server for example “w00tw00t.at.ISC.SANS” using iptables?

iptables -I INPUT -p tcp --dport 80 -m string --algo bm  \
--string 'GET /w00tw00t.at.ISC.SANS.' -j DROP
Comments Off on Howto: deny/allow IP using iptables

Howto: enable HTTP Compression

October 10, 2009    |   Posted by admin   |    Category: Linux Administration

How to enable HTTP Compression? In order to enable compression, you will need compression modules compiled with Apache. Apache 1.x needs mod_gzip and Apache 2.x need mod_deflate compiled with it.

If  you have these module installed, you need to edit your Apache configuration file locate at “/etc/httpd/conf/httpd.conf” file and add the following lines to it:

<Location />
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI  \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
</Location>

Save the file and restart the httpd service. This will compress all the files except the .gif, .jpe, .jpeg and .png files.

Related URLs:
How to enable http compression on a Plesk server?

-bash: locate: command not found

October 6, 2009    |   Posted by admin   |    Category: Linux Administration

“locate” command is use to index and quickly search for files on your system. If you receive the error message

-bash: locate: command not found

which indicates that the package “slocate” isn’t installed on your server. First check the output of

rpm -qa | grep slocate

if you don’t see any output it states that “slocate” is not installed on your server. You should be able to install slocate using

yum install slocate

as root. Once installed, execute “updatedb” to keep the database up-to-date.

Comments Off on -bash: locate: command not found

PHP pages asking for download

October 4, 2009    |   Posted by admin   |    Category: Linux Administration

If your .php files are prompting for download on browsing, make sure PHP is compiled with Apache and you have following lines in your Apache configuration file

AddHandler application/x-httpd-php .php .html

You can also add the above line in your .htaccess file of the domain.

Comments Off on PHP pages asking for download