Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung Nächste ÜberarbeitungBeide Seiten der Revision | ||
centos:mail_c6:mta_14 [18.03.2014 19:41. ] – [Postfix] django | centos:mail_c6:mta_14 [27.05.2014 18:58. ] – SRS - Sender Rewriting Scheme unter CentOS 6 django | ||
---|---|---|---|
Zeile 170: | Zeile 170: | ||
==== Postfix ==== | ==== Postfix ==== | ||
- | Leider unterstützt der aus dem Base-Repository stammende Postfix in der Version 2.6.6 keine TCP Lookup Tabellen, so dass wir auf eine neuere Version ausweichen müssen. Die Firma [[http:// | + | Leider unterstützt der aus dem Base-Repository stammende Postfix in der Version 2.6.6 keine TCP Lookup Tabellen, so dass wir auf eine neuere Version ausweichen müssen. |
+ | |||
+ | Die Firma [[http:// | ||
Wir laden uns also die entsprechenden RPM-Pakete auf unseren Server, dazu wechslen wir aber erst in unser lokales Programmarchiv. | Wir laden uns also die entsprechenden RPM-Pakete auf unseren Server, dazu wechslen wir aber erst in unser lokales Programmarchiv. | ||
Zeile 235: | Zeile 237: | ||
==== SRS-Deamon ==== | ==== SRS-Deamon ==== | ||
- | Das Programm-Archiv von **PostSRSd** | + | Als laden wir uns das aktuelle RPM auf unseren |
+ | # cd / | ||
- | In unserem Beispielsfall wurde die Installation von **cmake** und die Übersetzung von **PostSRSd** auf einem Entwicklungsrechner vorgenommen. Das übersetzte Programmpaket wurde anschließend auf den Mailserver kopiert und ist auch im Repository von nausch.org unter der [[http:// | + | # wget http:// |
- | Wollen | + | Dann installieren |
- | # | + | # |
- | Anschließend entpacken | + | Altenativ können |
- | # unzip master | + | # yum localinstall http://repository.nausch.org/public/x86_64/postsrsd-1.0.1-1.el6.x86_64.rpm |
- | < | + | |
- | 6c0be7c5b306a354f082e4fc2bbc7b517361157f | + | |
- | | + | |
- | inflating: postsrsd-master/.gitignore | + | |
- | | + | |
- | inflating: postsrsd-master/CMakeLists.txt | + | |
- | inflating: postsrsd-master/LICENSE | + | |
- | inflating: postsrsd-master/ | + | |
- | | + | |
- | inflating: postsrsd-master/makefile | + | |
- | inflating: postsrsd-master/ | + | |
- | inflating: postsrsd-master/postsrsd.apparmor.in | + | |
- | inflating: postsrsd-master/postsrsd.c | + | |
- | inflating: postsrsd-master/postsrsd.default | + | |
- | inflating: | + | |
- | inflating: postsrsd-master/ | + | |
- | inflating: postsrsd-master/ | + | |
- | inflating: postsrsd-master/ | + | |
- | inflating: postsrsd-master/ | + | |
- | inflating: postsrsd-master/ | + | |
- | </ | + | |
- | Bevor wir das Programm übersetzen, | + | |
- | # cd postsrsd-master | + | |
- | Nun übersetzen wir das Programm mit folgendem Aufruf. | + | Ein Update des Paketes geht entsprechend der Installation. |
- | # | + | # |
- | Das wars dann auch schon mit der Installation. Wir kopieren das erhaltene Binary an die entsprechende Stelle | + | Was uns das Paket alles mitbringt, zeigt uns wie immer der Aufruf von **rpm -qil < |
- | # cp build/postsrsd /usr/local/sbin/ | + | # rpm -qil postsrsd |
+ | < | ||
+ | Version | ||
+ | Release | ||
+ | Install Date: Fri 28 Mar 2014 11:14:34 AM CET Build Host: vml010039.intra.nausch.org | ||
+ | Group : System Environment/Daemons | ||
+ | Size : 41781 License: GPLV2+ | ||
+ | Signature | ||
+ | Packager | ||
+ | URL : https://github.com/ | ||
+ | Summary | ||
+ | Description : | ||
+ | PostSRSd provides the Sender Rewriting Scheme (SRS) via TCP-based | ||
+ | lookup tables for Postfix. SRS is needed if your mail server acts | ||
+ | as forwarder. | ||
+ | / | ||
+ | / | ||
+ | /usr/ | ||
+ | /usr/share/ | ||
+ | / | ||
+ | /usr/share/doc/ | ||
+ | / | ||
+ | </code> | ||
- | Wollen wir das Binary aus dem Repository von nausch.org nutzen, wechseln wir in das Zielverzeichnis und holen uns das Binary auf unseren Mailserver und passen zum Schluß noch die Dateioptionen an. | ||
- | # cd / | ||
- | |||
- | # wget http:// | ||
- | |||
- | # chmod +x / | ||
- | |||
- | Nun benötigen wir noch ein passendes Shell-Script für unseren **PostSRSd**. | ||
- | # vim / | ||
- | <file bash / | ||
- | # | ||
- | # postsrsd | ||
- | # | ||
- | # chkconfig: | ||
- | # description: | ||
- | # the popular and secure Postfix Mail Transport Agent | ||
- | # processname: | ||
- | # pidfile: | ||
- | # config: | ||
- | # sec-key: | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Required-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # the popular and secure Postfix Mail Transport Agent | ||
- | ### END INIT INFO | ||
- | |||
- | # Source function library. | ||
- | . / | ||
- | |||
- | # Source networking configuration. | ||
- | . / | ||
- | |||
- | RETVAL=0 | ||
- | POSTSRSD_CONFIG="/ | ||
- | NAME=" | ||
- | DAEMON="/ | ||
- | PID_FILE="/ | ||
- | SCRIPTNAME="/ | ||
- | DESC=" | ||
- | |||
- | if [ -f $POSTSRSD_CONFIG ]; then | ||
- | . $POSTSRSD_CONFIG | ||
- | else | ||
- | exit 0 | ||
- | fi | ||
- | |||
- | test -x $DAEMON || exit 0 | ||
- | |||
- | # Read config file if it is present. | ||
- | if [ -r / | ||
- | then | ||
- | . / | ||
- | fi | ||
- | |||
- | do_start() | ||
- | { | ||
- | echo -n " | ||
- | daemon $DAEMON -4 -f" | ||
- | | ||
- | RETVAL=$? | ||
- | echo | ||
- | [ $RETVAL -eq 0 ] && touch / | ||
- | return $RETVAL | ||
- | } | ||
- | |||
- | do_stop() | ||
- | { | ||
- | echo -n " | ||
- | killproc $NAME | ||
- | RETVAL=$? | ||
- | echo | ||
- | [ $RETVAL -eq 0 ] && rm -f / | ||
- | return $RETVAL | ||
- | } | ||
- | |||
- | case " | ||
- | start) | ||
- | do_start | ||
- | ;; | ||
- | stop) | ||
- | do_stop | ||
- | ;; | ||
- | status) | ||
- | status $NAME | ||
- | ;; | ||
- | restart|force-reload) | ||
- | do_stop | ||
- | do_start | ||
- | ;; | ||
- | reload) | ||
- | ;; | ||
- | condrestart|try-restart) | ||
- | if [ -f / | ||
- | do_stop | ||
- | do_start | ||
- | fi | ||
- | ;; | ||
- | *) | ||
- | echo " | ||
- | [ " | ||
- | exit 2 | ||
- | ;; | ||
- | esac | ||
- | exit $? | ||
- | </ | ||
===== Konfiguration ===== | ===== Konfiguration ===== | ||
==== SRS-Deamon ==== | ==== SRS-Deamon ==== | ||
- | Auf unserem Entwicklungsrechner finden wir eine README-Datei | + | Die Konfiguration des **postsrsd**-Daemons gestaltet sich vergleichsweise einfach und erfolgt lediglich mit Hilfe Der Datei //**/etc/sysconfig/postsrsd**//. |
- | # less /usr/local/ | + | Mit unserem Editor der Wahl, z.B. vim bearbeiten wir diese Konfigurationsdatei. |
- | + | # vim /etc/sysconfig/postsrsd | |
- | <file bash README.md> | + | <file bash /etc/sysconfig/ |
- | About | + | |
- | ===== | + | |
- | PostSRSd provides the Sender Rewriting Scheme (SRS) via TCP-based | + | |
- | lookup tables for Postfix. SRS is needed if your mail server acts | + | |
- | as forwarder. | + | |
- | + | ||
- | Imagine your server receives a mail from alice@example.com | + | |
- | that is to be forwarded. If example.com uses the Sender Policy Framework | + | |
- | to indicate that all legit mails originate from their server, your | + | |
- | forwarded mail might be bounced, because you have no permission to send | + | |
- | on behalf of example.com. The solution is that you map the address to | + | |
- | your own domain, e.g. | + | |
- | SRS0+xxxx=yy=example.com=alice@yourdomain.org (forward SRS). If the | + | |
- | mail is bounced later and a notification arrives, you can extract the | + | |
- | original address from the rewritten one (revere SRS) and return the | + | |
- | notification to the sender. You might notice that the reverse SRS can | + | |
- | be abused to turn your server into an open relay. For this reason, xxxx | + | |
- | and yy are a cryptographic signature and a time stamp. If the signature | + | |
- | does not match, the address is forged and the mail can be discarded. | + | |
- | + | ||
- | Building | + | |
- | ======== | + | |
- | PostSRSd requires a POSIX compatible system and CMake to build. | + | |
- | Optionally, help2man is used to create a manual page. | + | |
- | + | ||
- | For convenience, | + | |
- | the recommended command line options. Just run `make`. | + | |
- | + | ||
- | Installing | + | |
- | ========== | + | |
- | Run `make install` as root to install the daemon and the configuration | + | |
- | files. | + | |
- | Configuration | + | |
- | ============= | + | |
- | The configuration is located in `/etc/default/postsrsd`. You must store | + | |
- | at least one secret key in `/etc/postsrsd.secret`. The installer tries to generate | + | |
- | one from `/ | + | |
- | because anyone who knows it can use your mail server as open relay! | + | |
- | Each line of `/ | + | |
- | used for signing and verification, | + | |
- | + | ||
- | PostSRSd exposes its functionality via two TCP lookup tables. The | + | |
- | recommended Postfix configuration is to add the following fragment to | + | |
- | your main.cf: | + | |
- | + | ||
- | sender_canonical_maps = tcp: | + | |
- | sender_canonical_classes = envelope_sender | + | |
- | recipient_canonical_maps = tcp: | + | |
- | recipient_canonical_classes= envelope_recipient | + | |
- | + | ||
- | This will transparently rewrite incoming and outgoing envelope addresses. | + | |
- | Run `service postsrsd start` and `postfix reload` as root, or reboot. | + | |
- | </ | + | |
- | + | ||
- | Wir legen uns nun im ersten Schritt für unsere | + | |
- | # vim /etc/default/postsrsd | + | |
- | + | ||
- | <file bash /etc/default/ | + | |
# Local domain name. | # Local domain name. | ||
Zeile 455: | Zeile 288: | ||
# is taken from `postconf -h mydomain` and probably okay. | # is taken from `postconf -h mydomain` and probably okay. | ||
# | # | ||
- | # Django : 2014-03-17 | + | # |
- | # default: # | + | # Django : 2014-03-27 |
SRS_DOMAIN=nausch.org | SRS_DOMAIN=nausch.org | ||
Zeile 470: | Zeile 303: | ||
# and stored in / | # and stored in / | ||
# | # | ||
+ | # | ||
+ | # Django : 2014-03-27 | ||
SRS_SECRET=/ | SRS_SECRET=/ | ||
Zeile 478: | Zeile 313: | ||
# the internet. | # the internet. | ||
# | # | ||
+ | # | ||
+ | # | ||
+ | # Django : 2014-03-27 | ||
SRS_FORWARD_PORT=10001 | SRS_FORWARD_PORT=10001 | ||
SRS_REVERSE_PORT=10002 | SRS_REVERSE_PORT=10002 | ||
Zeile 486: | Zeile 324: | ||
RUN_AS=nobody | RUN_AS=nobody | ||
</ | </ | ||
- | |||
- | Zum Signieren der umgeschriebenen Adressen benötigen wir noch einen secret-key, den wir nun anlegen. | ||
- | # dd if=/ | ||
- | |||
- | Anschließend setzen wir die Dateirechte unseres privat-keys, | ||
- | # chmod 400 / | ||
- | |||
==== Postfix ==== | ==== Postfix ==== | ||
Zeile 514: | Zeile 345: | ||
...</ | ...</ | ||
+ | ===== Programmstart ===== | ||
+ | ==== erster manueller Start des Daemon ==== | ||
+ | Nun können wir das erste mal **PostSRSd** anstarten. | ||
+ | # service postsrsd start | ||
+ | |||
+ | Starting Postfix Sender Rewriting Scheme Daemon: | ||
+ | |||
+ | In der Prozessliste finden wir mindestens einen neuen Prozess, der gestartet wurde: | ||
+ | # ps aux | grep postsrsd | ||
+ | |||
+ | nobody | ||
+ | nobody | ||
+ | nobody | ||
+ | nobody | ||
+ | |||
+ | Mittels **netstat** können wir überpfüfen, | ||
+ | # netstat -tulpen | grep 1000 | ||
+ | |||
+ | tcp 0 0 127.0.0.1: | ||
+ | tcp 0 0 127.0.0.1: | ||
+ | |||
+ | Läuft unser Daemon kann mit Hilfe von **lsof** sehen wir nicht nur den geöffneten port, sondern auch die Verbindungen die dort anliegen. | ||
+ | # lsof -i :10001 | ||
+ | |||
+ | COMMAND | ||
+ | postsrsd 6170 nobody | ||
+ | postsrsd 7151 nobody | ||
+ | cleanup | ||
+ | postsrsd 7300 nobody | ||
+ | postsrsd 7300 nobody | ||
+ | postsrsd 7301 nobody | ||
+ | |||
+ | # lsof -i :10002 | ||
+ | |||
+ | postsrsd 6170 nobody | ||
+ | smtpd 7146 postfix | ||
+ | postsrsd 7151 nobody | ||
+ | postsrsd 7151 nobody | ||
+ | cleanup | ||
+ | postsrsd 7300 nobody | ||
+ | postsrsd 7301 nobody | ||
+ | postsrsd 7301 nobody | ||
+ | |||
+ | ==== automatisches Starten des Dienste beim Systemstart | ||
+ | Damit der Deamon **PostSRSd** automatisch bei jedem Systemstart startet, denn ohne laufenden **postsrsd** verweigert nun unser **postfix** die Annahme der Nachrichten, | ||
+ | # chkconfig postsrsd on | ||
+ | |||
+ | Die Überprüfungung ob postsrsd wirklich bei jedem Systemstart automatisch mit gestartet werden, kann durch folgenden Befehle erreicht werden: | ||
+ | # chkconfig --list | grep postsrsd | ||
+ | |||
+ | | ||
+ | Wichtig sind jeweils die Schalter **on** bei den Runleveln - **2 3 4 5**. | ||
+ | |||
+ | ===== Umschreibungen / Logging ===== | ||
+ | Im Maillog unseres Mailservers werden die Umschreibungen entsprechend dokumentiert. | ||
+ | # less / | ||
+ | |||
+ | Mar 18 21:01:59 vml000080 postsrsd[5806]: | ||
+ | |||
+ | Im Header zugestellten eMail beim Empfänger wird dies auch im **Return-Path**hinterlegt. | ||
+ | Return-Path: | ||
+ | |||
+ | Bounced das Zielsystem die Nachricht, weil dieses z.B. die Nachricht wegen einer vollen Mailbox nicht zustellen kann, kann das relayende System nun problemlos den eigentlichen Absender informieren, | ||
+ | Mar 13 21:27:25 vml000080 postsrsd[6883]: | ||
+ | ... | ||
+ | ... | ||
+ | Mar 18 21:27:26 vml000080 postfix/ | ||
+ | ====== Links ====== | ||
+ | * **[[centos: | ||
+ | * **[[wiki: | ||
+ | * **[[http:// | ||
- | FIXME //... coming soon...// FIXME | + | ~~DISCUSSION~~ |
+ | ~~AUTOTWEET: |