postfwd_v2

 

 

 


Install

 

wget https://postfwd.org/postfwd-2.03.tar.gz

tar -zxf postfwd-2.03.tar.gz

mv postfwd /opt

ln -s /opt/postfwd/sbin/postfwd /usr/sbin

Requirement

yum install -y perl-Net-IP

Add user for run daemon

useradd -r -d /var/run/postfwd -s /bin/false -c "postfwd daemon user" postfwd -m

passwd -l postfwd

Start

Base=/opt/postfwd

$Base/sbin/postfwd --daemon -f $Base/etc/postfwd.cf -u postfwd -g postfwd

Remark

Port: 10045/tcp

Checking

netstat -ntlp | grep 10040

Stop

killall postfwd

 


Postfix Config

 

/etc/postfix/main.cf

smtpd_recipient_restrictions = permit_mynetworks,  # recommended
  ...,                                             # optional
  reject_unauth_destination,                       # **postfwd integration**
  check_policy_service inet:127.0.0.1:10040,       # 
  ...   

Postfwd Rule: /opt/postfwd/etc/postfwd.cf

id=DEFAULT; action=DUNNO

Test: 寄信入去會有以下 log

Dec  7 17:34:31 mail postfwd3/policy[3018]: [RULES] rule=0, id=DEFAULT,
  client=unknown[202.181.201.11], sender=<tim@MyDomain>,
  recipient=<datahunter@datahunter.org>,
  helo=<mail.MyDomain>,
  proto=ESMTP, state=RCPT, delay=0.00s, hits=DEFAULT, action=DUNNO

 


Postfwd Setting

 

# exports program settings to stdout

postfwd --showsettings

# loads program settings from <file>

-F, --loadsettings <file>

# Basic Setting

{

  Configs => [
               'file////opt/postfwd/etc/postfwd.cf',
               'rule///id=DEFAULT; action=DUNNO'
             ],

  base => { group => 'postfwd', user  => 'postfwd' },

  server => {
              proto => 'tcp',
              host  => '127.0.0.1',
              port  => '10045',
              max_servers => '10',
              max_spare_servers => '5',
              min_servers => '2',
              min_spare_servers => '1'
            },

  daemon => 1,

  verbose => 0,

}

postfwd -F /opt/postfwd/etc/postfwd.settings

說明

--keep_groups                    do not clear group cache on reload  

--keep_rates                      do not clear rate limit counters on reload

--max_servers <i>              do not spawn more than <i> children

--max_spare_servers <i>     maximum idle children

--min_servers <i>                spawn at least <i> children

-S, --summary <i>               show stats every <i> seconds

-t, --test                             testing, always returns "dunno"

--pidfile /path/to/file


Statistics

 

postfwd --dumpcache                 # show cache contents

postfwd --dumpstats                 # show statistics