postfix-2.8.0-RC3
postfix-2.9-20110116 RPM SOURCE
postfix-2.8-20110105 rpm source
Postfix Randomizing Outgoing IP Using TCP_TABLE And Perl
This time i’ll show you how to randomize your smtp outbound’s IP addresses. This can be done via transport map. But, since ordinary Postfix lookup tables store information as (key, value) pairs. it will provide static value only. we need someting that can manipulate the value (right hand side) of a lookup table. In order to answer random transport value.
first come to mind was tcp_tables, tcp_tables lookup table gives some flexibility for us to execute our tiny perl script that will randomizing transport. that’s the basic idea.
Ok, here’s the first part, create perl script call random.pl, anyway this script only provide answer in “catch-all” manner. so it will randomized, all outgoing mail.
1 | # cd /etc/postfix |
2 | # vi random.pl |
1 | #!/usr/bin/perl -w |
2 | # author: Hari Hendaryanto <hari.h -at- csmcom.com> |
3 |
4 | use strict; |
5 | use warnings; |
6 | use Sys::Syslog qw(:DEFAULT setlogsock); |
7 |
8 | # |
9 | # our transports array, we will define this in master.cf as transport services |
10 | # |
11 |
12 | our @array = ( |
13 | 'rotate1:' , |
14 | 'rotate2:' , |
15 | 'rotate3:' , |
16 | 'rotate4:' , |
17 | 'rotate5:' |
18 | ); |
19 |
20 | # |
21 | # Initalize and open syslog. |
22 | # |
23 | openlog('postfix/randomizer','pid','mail'); |
24 |
25 | # |
26 | # Autoflush standard output. |
27 | # |
28 | select STDOUT; $|++; |
29 |
30 | while (<>) { |
31 | chomp ; |
32 | # randomizing transports array |
33 | my $random_smtp = int ( rand ( scalar ( @array ))); |
34 | if (/^get\s(.+)$/i) { |
35 | print "200 $array[$random_smtp]\n" ; |
36 | syslog( "info" , "Using: %s Transport Service" , $random_smtp ); |
37 | next ; |
38 | } |
39 |
40 | print "200 smtp:" ; |
41 | } |
Postfix header_checks using tcp_table and checkdbl.pl script
Postfix implements the header_checks as built-in content inspection classes while receiving mail. Usually the best performance is obtained with pcre (Perl Compatible Regular Expression) tables or slower regexp (POSIX regular expressions). Googling on the net, i’ve found tiny perl script that can queries to dbl.spamhaus.org, multi.surbl.org, black.uribl.com. ( Sahil Tandon wrote it, based on João Gouveia perl script, i think..)
first download the script
1 | # cd /etc/postfix |
2 | # wget http://people.freebsd.org/~sahil/scripts/checkdbl.pl.txt |
Rename and make it executable
1 | # mv checkdbl.pl.txt checkdbl.pl |
2 | # chmod 755 checkdbl.pl |
Edit master.cf add this two lines
1 | 127.0.0.1:2526 inet n n n - 0 spawn |
2 | user=nobody argv=/etc/postfix/checkdbl.pl |
Make preliminary test, to ensure checkdb.pl sih really spawned and answering our queries
1 | # postfix reload |
2 | # telnet 127.0.0.1 2526 |
amavisd-new with AVG 8.5 free Edition for Linux
I’m evaluating the AVG 8.5 free Edition for Linux on Centos 5. It’s fairly easy step to setup. Just download the installer, install, update virus definition database.tweak some avgtcpd’s config and voila!! it’s running smoothly. Here’s the step everyone might want to know.
Download avg 8.5 installer
Install
1 | $ sudo rpm -ivh avg85flx-r863-a3205.i386.rpm |
start the service (in this case i was using init.d script)
1 | $ sudo /etc/init.d/avgd start |
Verify if avgtcpd is running
1 | $ sudo netstat -pltn | grep avgtcpd |
2 | tcp 0 0 127.0.0.1:54321 0.0.0.0:* LISTEN 10839/avgtcpd |
3 | tcp 0 0 127.0.0.1:54322 0.0.0.0:* LISTEN 10839/avgtcpd |
Update virus definition database
1 | $ sudo avgupdate |
Nginx worker_cpu_affinity
By Default, without setting worker_cpu_affinity directive in nginx.conf, linux kernel will spread all nginx’s worker all over CPUs.
I have 4 logical CPUs on my server, which is CPU0 – CPU3
1 | Cpu0 : 2.9%us, 0.9%sy, 0.0%ni, 88.9%id, 7.2%wa, 0.0%hi, 0.2%si, 0.0%st |
2 | Cpu1 : 1.8%us, 0.6%sy, 0.0%ni, 95.3%id, 2.2%wa, 0.0%hi, 0.1%si, 0.0%st |
3 | Cpu2 : 2.4%us, 0.7%sy, 0.0%ni, 94.3%id, 2.5%wa, 0.0%hi, 0.1%si, 0.0%st |
4 | Cpu3 : 1.9%us, 0.7%sy, 0.0%ni, 96.7%id, 0.6%wa, 0.0%hi, 0.0%si, 0.0%st |
Using default setting, nginx’s worker always bind to those 4 logical CPUs. which is has “f” bitmask
1 | # taskset -p 12348 |
2 | pid 25748's current affinity mask: f |
3 | # taskset -p 12349 |
4 | pid 25749's current affinity mask: f |
5 | # taskset -p 12351 |
6 | pid 25751's current affinity mask: f |
7 | # taskset -p 12352 |
8 | pid 25752's current affinity mask: f |
9 | # taskset -p 12353 |
10 | pid 25753's current affinity mask: f |
CPU affinity is represented as a bitmask (given in hexadecimal), with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU.
Examples:
How To Make php-fpm Listen On Both Tcp And Unix Socket?
I need to make php-fpm listeing on both tcp/unix socket, and this is how it done.
(this was not pretty workarround i guess, but it work )
first download php rpm source
Compile and install
1 | $ rpmbuild --rebuild php-5.3.3-2.el5.src.rpm |
2 | $ sudo rpm -Uvh /path/to/RPMS/php-* |
Configuring the default php-fpm for using tcp socket
Edit www.conf
1 | $ sudo vi /etc/php-fpm.d/www.conf |
Find line containing
1 | listen = 127.0.0.1:9000 |
We can make it listening to port what ever we desire, ie 9001 etc
Start php-fpm first instance
1 | $ sudo service php-fpm start |
Configuring php-fpm for using unix socket
1 | $ sudo cp /etc/php-fpm.conf /etc/php-fpm2.conf |
2 | $ sudo cp -rp /etc/php-fpm.d /etc/php-fpm2.d |
Edit /etc/php-fpm2.conf
1 | include=/etc/php-fpm2.d/*.conf |
2 | pid = /var/run/php-fpm/php-fpm2.pid |
3 | error_log = /var/log/php-fpm/error2.log |
Edit /etc/php-fpm2.d/www.conf
1 | listen = /tmp/php-fpm.sock |
2 | php_admin_value[error_log] = /var/log/php-fpm/www-error2.log |