Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:skoleni:mailserver [2014/04/25 09:45]
admin
linux:skoleni:mailserver [2014/05/02 00:50] (current)
admin [SPF, cast druha]
Line 422: Line 422:
   flags=DRhu user=vmail:​vmail argv=/​usr/​lib/​dovecot/​deliver -d ${user}@${nexthop}   flags=DRhu user=vmail:​vmail argv=/​usr/​lib/​dovecot/​deliver -d ${user}@${nexthop}
 </​file>​ </​file>​
 +
 +
 +====== Antispam, antivir, blacklisty a greylisting ========
 +<​code>​
 +apt-get install amavis clamav
 +</​code>​
 +Odkomentovat v /​etc/​amavis/​conf.d/​15-content-filter-mode radky pro predani e-mailu ke kontrole
 +<file perl /​etc/​amavis/​conf.d/​15-content-filter-mode>​
 +@bypass_virus_checks_maps = (
 +   ​\%bypass_virus_checks,​ \@bypass_virus_checks_acl,​ \$bypass_virus_checks_re);​
 +@bypass_spam_checks_maps = (
 +   ​\%bypass_spam_checks,​ \@bypass_spam_checks_acl,​ \$bypass_spam_checks_re);​
 +</​file>​
 +
 +<file bash main.cf>
 +# Anti spam/​vir/​komunista
 +content_filter = zabijak:​[127.0.0.1]:​10024
 +</​file>​
 +
 +<file bash master.cf>​
 +zabijak ​   unix  -       ​- ​      ​- ​      ​- ​      ​5 ​       smtp
 +        -o smtp_data_done_timeout=1200
 +        -o smtp_send_xforward_command=yes
 +127.0.0.1:​10025 inet n -        -       ​- ​      ​- ​       smtpd
 +        -o content_filter=
 +        -o local_recipient_maps=
 +        -o relay_recipient_maps=
 +        -o smtpd_restriction_classes=
 +        -o smtpd_client_restrictions=
 +        -o smtpd_helo_restrictions=
 +        -o smtpd_sender_restrictions=
 +        -o smtpd_recipient_restrictions=permit_mynetworks,​reject
 +        -o mynetworks=127.0.0.0/​8
 +        -o strict_rfc821_envelopes=yes
 +        -o receive_override_options=no_unknown_recipient_checks,​no_header_body_checks
 +</​file>​
 +
 +====== SPF - cast prvni======
 +Kdyz jsme venovali tolik prace DNS, ukazeme si pomerne hezkou antispamovou techniku. Jedna se o hlubsi overovani domeny odesilatele. Konkretne se dotazeme serveru jahoda.cz, jestli adresa 1.2.3.4 mohla odeslat e-mail From:<​nekdo@jahoda.cz>​.
 +
 +Pokud spravce domeny jahoda.cz presne vi, ze vsichni jeho uzivatele pouzivaji jeden centralni server, vuci kteremu se overuji a odesilaji pres nej postu, pak muze vesele do DNS napsat informaci:
 +"Mame jeden centralni server pres ktery odesilame postu na IPv4: 9.8.7.6, jine jsou podvod."​
 +
 +Akorat se to zapisuje takto:
 +  jahoda.cz. IN TXT "​v=spf1 ip4:9.8.7.6 -all"
 +
 +Zaznamy, ktere nemaji pred sebou znamenko +/- se berou, jako by mely +. Tedy "​+ipv4"​ v nasem prikladu.
 +
 +Vysvetleni:
 +  * spf1 - zaznam popisuje Sender Policy Framework
 +  * ipv4 - oznamuje ip aderesu, ktera patri mezi povolene
 +  *  -all - oznamuje ze vse ostatni je neplatne
 +
 +Kdyby nekoho zajimalo, jak vypada nas SPF zaznam, tady je:
 +   ​starlab.cz. IN TXT "​v=spf1 mx -all".
 +Promite mi, ze to sem pisu, vdyt' vsichni umite
 +   host -t txt starlab.cz
 + 
 +**Upozorneni:​ Tim ovsem pomahate jen druhym, aby e-maily s vasi podvrzenou domenou nikde nezpusobovali spam.** Jeste je potreba take nastavit druhou cast tj. implementovat ochranu na vlastnim serveru.
 +
 +====== SPF - cast druha =======
 +Zarazeni do postfixu je obvykla trojkombinace
 +   * apt-get install <​neceho>​
 +   * pridani do main.cf
 +   * pridani do master.cf
 +A pak trocha ladeni a opravovani preklepu.
 +
 +Existuje python i perl verze. ​
 +   ​apt-get install postfix-policyd-spf-python
 +   ​apt-get install postfix-policyd-spf-perl
 +Pro ty co se nudi mohou napsat pojednani, jaky je mezi nimi rozdil.
 +
 +Do ''​main.cf''​ pridame kamkoliv <​code>​policy-spf_time_limit = 3600s</​code>​
 +
 +A do ''​master.cf''​ pridame treba pythonovsky skript
 +<​code>​
 +policy-spf ​ unix  -       ​n ​      ​n ​      ​- ​      ​- ​      spawn
 +     ​user=nobody argv=/​usr/​bin/​policyd-spf
 +</​code>​
 +
 +A obohatime ​ ''​smtpd_recipient_restrictions''​ v main.cf: ​
 +
 +<​code>​
 +smtpd_recipient_restrictions =
 +     ...
 +     ​permit_sasl_authenticated
 +     ​permit_mynetworks
 +     ​reject_unauth_destination
 +     ​check_policy_service unix:​private/​policy-spf
 +</​code>​
 +
 +====== Sieve filtry v akci ======
 +Globalni filtr pro razeni spamu vsem uzivatelum do slozky spam.
 +<file text /​srv/​mail/​globalsieverc>​
 +require "​fileinto";​
 +if header :contains "​X-Spam-Flag"​ "​YES"​ {
 +  fileinto "​spam";​
 +  stop;
 +}
 +</​file>​
 +====== Ladeni vykonu a statistiky ======
 +<​code>​
 +apt-get install mailgraph
 +apt-get install collectd --no-install-recommends
 +</​code>​
 +
 +======= Automaticka odpoved v dobe nepritomnosti ======
 +<file postfix master.cf>​
 +moje_prazdniny unix  -       ​n ​      ​n ​      ​- ​      ​- ​      pipe
 +  flags=Rq user=autoreply argv=/​home/​autoreply/​autoreply.pl -f ${sender} -- ${recipient}
 +</​file>​
 +
 +<file base64 vacation.pl.gz.base64>​
 +H4sICKCBWlMAA3ZhY2F0aW9uLnBsAK1Ze3fTyA7/​m3wK4bYnzjaPBpZ9JLTbkoZL7iltTxPY5dCS
 +dewJma1jG3vStIf2fvYrafyKHQIXbnpI7BlJI/​2kkTTD1uPWIgpbE+m1AhG60FhWtipb8FaGamG5
 +8NayLSV9D5422zg8uYPXMrJnFpwLJcIIns/​1q6VgJj/​OnoHjK/​CEOkDinh/​chTiowLRr8GRv7wk0
 +6OcZvCLSx0hyIm3hRQIG3tTvwEypoNNqLZfLZuBHaipvLWcuvabtz1t/​TKUr9k8Gvf7psN8c/​TVi
 +NY8cR5J6UQdfUPTPrb1fW+2nAMfWjXTgLJr4oQfP/​ShyxA0p6Vi+7bNE0jD/​iVQobVWHIPRtEUUi
 +QlPml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FLi6RVlnqPcbJbY/​ULdRYZ6TZp
 +nLU//​Bp3RvzM7RE/​pc3WV080iThqA76hXv3fDi+57PNtAU+86dmtgAmf3SjaNNDd1AXpAds03g/​7
 +eCy76A/​Pz06H/​StOVwWwOnzENAiFpP0AM0a2k2Jc01Sjs05udT02fPPi3whqZ9VVeu7tEZ69Bmen
 +kBHpjVqYfnF2/​C6ea1/​lW5GkK15jez2RVU8Y81zcdBVMLYdMPpCSY1lyFqEw3fryBzgZbCDQH75m
 +Wu3lbXuloc/​Clu+KRtY1XX1ZDl02W4EVqspyRkch8/​lwdDw4PYhjyLUw8VF8tD5st2pppLU+0FKd
 +y2jXbP6EXttuSYoRfVjBYGt3s2NW6wO6uESJVaVEZ9tlOtsu08VWlYmTw1GJI7a+QYFYZMpOTyW2
 +gEqPIzxbMNtk4V7fuzJS9/​8svOua5uc21tyrrTDeNqjbJab4rvQS+Lb0Em700eEyzQVlKRQRMJiC
 +kGqGOVafkHBL0VmI7tI8X2FWQ6cSU4UWfKyBv7+HxwhsUV4lcYtrxzGiY6CXtHlSVbn98yc30l9E
 +nDKplKXyYwH/​gZb5/​nJ52WjuXO1eHuJjs3G1W2uVXZ8xiU9gGKRZJuODv/​RE2LhvmKHAzIZw8kDt
 +8vD+g0n7DycdS8x9757Qm2MI8mwZKTRiqEIZaGiw6evZ+jdYRDO6M5zTQYVzHW2QQ7o5D8a2Hac/​
 +yA0qXw9mJbsOP+E/​xowwRcw4TwqsXcKhwCRtCiLXchMlq8tamYUF60UZNX2zfxgJK7RnSaZOTdW5
 +Mz1yEajxPq5Q3i2Kj/​cxO2S82YWVR4mCuZUxdbR1snq0kvFHF4NzTPm9wfmgfzoaXnXAKNzFtDH1
 +NozsK3cTgbbwEvrefcUg/​X8nKx12bFZOqVqugnPd39hYjGsbKmShkr08e4OlLKkYa6zKp9ikWKQ5
 +vfJoXbthligLcvK5OYFor1v5L3Gl/​PBDHAAA
 +</​file>​
 +
 +======= LDAP =======
 +[[http://​www.howtoforge.com/​postfix-virtual-hosting-with-ldap-backend-and-with-dovecot-as-imap-pop3-server-on-ubuntu-karmic-koala-9.10-p2]]
 
linux/skoleni/mailserver.1398411901.txt.gz · Last modified: 2014/04/25 09:45 by admin