How to change SMTP server IP address in spam blacklist

Sometimes you want to temporarily use a secondary IP of your Linux server to connect to a remote server on a particular port.

It can be useful, for instance, if your SMTP server IP has been blacklisted for a temporary spam problem (caused by virus, account hacking, web exploit etc.).
After solving the problem, you may use a secondary IP in your server to bypass blacklists, giving time to main IP to “clean up”. To do so you can configure source NAT with iptables command.

iptables -t nat -A POSTROUTING -p tcp --dport 25 -j SNAT --to-source xx.xx.xx.xx

where xx.xx.xx.xx is a secondary IP of the server.
Now your mail will appear to originate from the secondary IP, without changing mail server configuration.

In the case of SMTP, it is important to be sure that the secondary IP has correct DNS resolutions, both inverse and direct, otherwise your mail may not be accepted by remote servers.

How to emulate a slow connection

Sometimes you would want to emulate a slow connection. For example to better understand a web site performance that you are developing locally.

As you probably know search engines (especially Google) prefers faster sites. Using a slow connection we can better assess the optimizations we may apply to the web application. Every second (or fraction of it) saved can make you earn positions on SERPs.

Linux lets you emulate a slow connection using netem kernel mode throuch tc command. Some examples:

# tc qdisc add dev eth0 root netem delay 300ms 30ms
# tc qdisc change dev eth0 root netem loss 0.10%

These commands will add a random delay between 300 and 30 ms and a packets loss of 0.10% to eth0 interface.
Other features and examples are visible here.

For Windows and Mac (and also linux) I recommend this Java “slow proxy”

You can contact me for advices on How to optimize a web site.

Watch out awstats upgrade with Plesk 10 and Centos 5

I recently had an unpleasant surprise updating packages on a Centos 5 server with Plesk 10.4.4.

The awstats statistics stopped working. The reason was the update of awstats-7.0-12012611.swsoft rpm with the update of Centos awstats-7.0-2.el5.rf .

I solved the problem by brutally removing the Centos package and reinstalling the Plesk one.

rpm -e --nodeps awstats 
rpm -ivh awstats-7.0-12012611.swsoft.noarch.rpm 

How to solve “mod_fcgid: read data timeout in 40 seconds” in centos 5

In Centos 5 mod_fcgid version there is a bug that causes this error:

mod_fcgid: read data timeout in 40 seconds

in VirtualHosts regardless of the values of IPCCommTimeout and IPCConnectTimeout configured in /etc/httpd/conf.d/fcgid.conf.

On the net I found a solution which consists in inserting in every VirtualHost the parameters IPCCommTimeout IPCConnectTimeout, but for me it worked just inserting the following code ad first VirtualHost:

<VirtualHost *:80>
Include conf.d/virtualfcgi.conf

and editing mod_fcgi parameters in file /etc/httpd/conf.d/virtualfcgi.conf

<IfModule mod_fcgid.c>
IdleTimeout 3600
ProcessLifeTime 7200
MaxProcessCount 64
DefaultMaxClassProcessCount 8
IPCConnectTimeout 300
IPCCommTimeout 7200
BusyTimeout 300