Setting up SPF INBOUND

bounce non authentified messages

Install

debian

apt install postfix-policyd-spf-python python3-spf python3-spf-engine
ls -lF /usr/bin/policyd-spf

slackware

slackware // python3

slackpkg install python3 python-pip python-setuptools
ln -s python3 /usr/bin/python

pip install py3dns pyspf pypolicyd-spf
#sbopkg -i python-pydns -i python-pyspf -i python-pypolicyd-spf
which policyd-spf
/usr/bin/policyd-spf -h
ls -alF /etc/python-policyd-spf/

slackware // perl // NOGO

perl-Mail-SPF
perl-NetAddr-IP perl-Net-DNS-Resolver-Programmable perl-net-dns perl-Module-Build

perl-Mail-SPF-Query
perl-Net-CIDR-Lite perl-Sys-Hostname-Long perl-net-dns

slackware // libspf2 // NOGO

#git clone https://github.com/shevek/libspf2.git
slackpkg install patch gc
sbopkg -i libspf2
wget https://www.libspf2.org/patch/policyd-1.0.1.tar.gz
...

Setup

debian

cd /etc/postfix-policyd-spf-python/

zcat /usr/share/doc/postfix-policyd-spf-python/policyd-spf.conf.commented.gz \
    > policyd-spf.conf.commented
grep -vE '^#|^$' policyd-spf.conf.commented > policyd-spf.conf.commented.clean

mv -i policyd-spf.conf policyd-spf.conf.dist
grep -vE '^#|^$' policyd-spf.conf.dist > policyd-spf.conf.clean
grep -vE '^#|^$' policyd-spf.conf.dist > policyd-spf.conf
vi policyd-spf.conf

Hide_Receiver = Yes

note that’s counter-intuitive but it is what it is

TestOnly = 1

slackware

configure the socket wrapper

#less pypolicyd-spf-2.0.2/policyd-spf.conf.commented
#cp -pi /etc/python-policyd-spf/policyd-spf.conf /etc/python-policyd-spf/policyd-spf.conf.dist
#grep -vE '^($|#)' /etc/python-policyd-spf/policyd-spf.conf.dist > /etc/python-policyd-spf/policyd-spf.conf
#vi /etc/python-policyd-spf/policyd-spf.conf

fix the error msg URL

cp -pi /usr/bin/policyd-spf /usr/bin/policyd-spf.dist
#sed 's/openspf\.org/open-spf.org/g' /usr/bin/policyd-spf.dist > /usr/bin/policyd-spf
sed 's/openspf\.net/open-spf.org/g' /usr/bin/policyd-spf.dist > /usr/bin/policyd-spf
chmod +x /usr/bin/policyd-spf

diff -bu /usr/bin/policyd-spf.dist /usr/bin/policyd-spf

and finally see the Hardening Postfix guide

TODO

switch to spf-engine instead – url is obsolete and the guy does not plan to maintain it

pypolicyd_spf reference to URL openspf.net? https://answers.launchpad.net/pypolicyd-spf/+question/678947

Trash

slackware

sbopkg -i libspf2
ls -lhF /usr/include/spf2/spf.h
ldd /usr/lib64/libspf2.so

slackpkg install autoconf

cd policyd-1.0.1/
CFLAGS="-O2 -I/usr/include/spf2" LIBS="-L /usr/lib64 -lspf2" ./configure

netbsd

pkg_add libspf2
...got policyd for libspf2?

python2

slackpkg install python2
sbopkg -i python-pypolicyd-spf

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
which pip
mv /usr/bin/pip /usr/bin/pip2
pip2 install pyspf pydns

python3

python-pip python-setuptools
pip list
pip install wheel
pip install pyspf pypolicyd-spf
which policyd-spf
/usr/bin/policyd-spf -h

#wget https://launchpad.net/pypolicyd-spf/2.0/2.0.2/+download/pypolicyd-spf-2.0.2.tar.gz
#tar xzf pypolicyd-spf-2.0.2.tar.gz 
#cd pypolicyd-spf-2.0.2

Resources

Postfix SMTP Access Policy Delegation http://www.postfix.org/SMTPD_POLICY_README.html

Software http://www.open-spf.org/Software/

libspf2 - SPF Library - Home https://www.libspf2.org/

libspf2 - SPF Library - Download https://www.libspf2.org/download.html

Implementation of the Sender Policy Framework for SMTP authorization http://www.libspf2.org/ https://github.com/shevek/libspf2

DEPRECATED AS PATCH - SPF patch for Postfix http://www.ipnet6.org/postfix/spf/

Postfix SPF readme https://www.libspf2.org/patch/postfix-libspf2.README

Postfix http://www.en.sysadmin-cookbook.com/postfix/

Implementations http://www.open-spf.org/action_browse_id_Implementations_revision_106/

too painful with perl

SPF Postfix Server Setup using postfix-policyd-spf-perl https://wiki.mattrude.com/Sender_Policy_Framework_(SPF)#SPF_Postfix_Server_Setup_using_postfix-policyd-spf-perl

postfix-policyd-spf-perl https://launchpad.net/postfix-policyd-spf-perl/

fixed with python3

https://stackoverflow.com/questions/41342551/error-installing-pydns

alternatives

https://www.tummy.com/software/tumgreyspf/

http://www.acme.com/software/spfmilter/

https://www.libspf2.org/patch/postfix-libspf2.README

https://www.libsrs2.org/index.html


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun