Configuratie files
Postfix
Postfix heeft meerdere configuratie files. Sommige zijn in hash format, andere vormen het interface naar MySQL. De eigenlike confuguratie van de MTA staat in main.cf en master.cf.
access
Wordt op het ogenblik niet gebruikt.
aliases
Alleen bit-bucket en de (verplichte) doorverwijzing van root toegevoegd. Uiteindelijk komt alles naar root.
main.cf
Hiet in staat de hele configuratie van de MTA. Alle wijzigingen t.o.v. default zijn op te vragen met postconf -n. In de configuratie file staat heel veel commentaar. Bovendien zijn alle keywords op te zoeken in de online documentatie. Een paar belangrijke instellingen:
- content_filter = smtp-amavis:[127.0.0.1]:10024. Zie master.cf waar het content filter wordt gedefinieerd.
- home_mailbox = Maildir/. Wat voor soort mailbox hebben de gebruikers. Postfix in combinatie met Dovecot gebruikt eigenlijk altijd Maildir format i.p.v. de platte mail file.
- mynetworks = 212.72.224.0/19, 172.31.1.0/24, 172.31.2.0/24, 127.0.0.0/8, [::ffff:127.0.0.0]/104, [::1]/128. Vanaf welke netwerken accepteren we mail.
- relay_domains = proxy:mysql:$config_directory/mysql_relay_domains_maps.cf. Lookup van relay domeinen. Wij relayeren niet op deze server. Zie ook onder MySQL *.cf files.
- smtp(d)_tls_CAfile = /etc/ssl/certs/cacert.org.pem. Lijst van root certificaten.
- smtp(d)_tls_cert_file = /disk/site/etc/ssl/hobby.nl/hobby.nl.crt. Ons wildcard certificaat.
- smtp(d)_tls_key_file = /disk/site/etc/ssl/hobby.nl/hobby.nl.key. De key van ons wildcard certificaat.
- transport_maps = hash:/etc/postfix/transport (zie onder transports). Doorverwijzingen naar andere (hidden) mailservers. Wij hebben één gebruiker die op deze manier zelf zijn mail afhandelt op een eigen mailserver.
- virtual_alias_maps = proxy:mysql:$config_directory/mysql_virtual_alias_maps.cf, proxy:mysql:$config_directory/mysql_virtual_alias_alias_maps.cf. De lookup van de aliassen.
- virtual_mailbox_domains = proxy:mysql:$config_directory/mysql_virtual_domains_maps.cf. De lookup van de domeinen.
- virtual_mailbox_maps = proxy:mysql:$config_directory/mysql_virtual_mailbox_maps.cf, proxy:mysql:$config_directory/mysql_virtual_mailbox_alias_maps.cf. De lookup van de mailboxen.
- virtual_transport = dovecot. Vertelt aan Postfix dat Dovecot wordt gebruikt als POP en IMAP server.
master.cf
In master.cf staan de processen die tot Postfix behoren. Bij ons zijn toegevoegd: mta3525 als alternatieve smtp poort, submission staat aan op poort 587. Verder zijn mailman en dovecot enabled. Onder de Filter Customizations is amavis toegevoegd (in en uit). Zoals al in main.cf te zien was, wordt het filter op poort 10024 aangesproken waarna het antwoord via 10025 terug komt.
# # Postfix master process configuration file. For details on the format # of the file, see the master(5) manual page (command: "man 5 master"). # # Do not forget to execute "postfix reload" after editing this file. # # ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) # ========================================================================== smtp inet n - - - - smtpd mta3525 inet n - - - - smtpd submission inet n - - - - smtpd -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING smtps inet n - - - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING #628 inet n - - - - qmqpd pickup fifo n - - 60 1 pickup cleanup unix n - - - 0 cleanup qmgr fifo n - n 300 1 qmgr #qmgr fifo n - - 300 1 oqmgr tlsmgr unix - - - 1000? 1 tlsmgr rewrite unix - - - - - trivial-rewrite bounce unix - - - - 0 bounce defer unix - - - - 0 bounce trace unix - - - - 0 bounce verify unix - - - - 1 verify flush unix n - - 1000? 0 flush proxymap unix - - n - - proxymap proxywrite unix - - n - 1 proxymap smtp unix - - - - - smtp # When relaying mail as backup MX, disable fallback_relay to avoid MX loops relay unix - - - - - smtp -o smtp_fallback_relay= # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 showq unix n - - - - showq error unix - - - - - error retry unix - - - - - error discard unix - - - - - discard local unix - n n - - local virtual unix - n n - - virtual lmtp unix - - - - - lmtp anvil unix - - - - 1 anvil scache unix - - - - 1 scache # # ==================================================================== # Interfaces to non-Postfix software. Be sure to examine the manual # pages of the non-Postfix software to find out what options it wants. # # Many of the following services use the Postfix pipe(8) delivery # agent. See the pipe(8) man page for information about ${recipient} # and other message envelope options. # ==================================================================== # # maildrop. See the Postfix MAILDROP_README file for details. # Also specify in main.cf: maildrop_destination_recipient_limit=1 # #maildrop unix - n n - - pipe # flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient} # # See the Postfix UUCP_README file for configuration details. # #uucp unix - n n - - pipe # flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) # # Other external delivery methods. # #ifmail unix - n n - - pipe # flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) #bsmtp unix - n n - - pipe # flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient #scalemail-backend unix - n n - 2 pipe # flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension} mailman unix - n n - - pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user} dovecot unix - n n - - pipe flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient} # ##### START OF CONTENT FILTER CUSTOMIZATIONS ##### # Please see the Postfix FILTER_README for details. # These sample entries expect your content filter to # listen on port 10025 and to inject mail back into # postfix on port 10026. # # to enable such content filter run the command # postconf -e content_filter=smtp-filter:127.0.0.1:10025 # postconf -e smtp-filter_destination_concurrency_limit=2 # or # postconf -e content_filter=lmtp-filter:127.0.0.1:10025 # postconf -e lmtp-filter_destination_concurrency_limit=2 # and the command # postconf -e receive_override_options=no_address_mappings # # 127.0.0.1:10025 inet n - y - - smtpd -o content_filter= -o smtpd_delay_reject=no -o smtpd_client_restrictions=permit_mynetworks,reject -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o smtpd_data_restrictions=reject_unauth_pipelining -o smtpd_end_of_data_restrictions= -o smtpd_restriction_classes= -o mynetworks=127.0.0.0/8 -o smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o smtpd_hard_error_limit=1000 -o smtpd_client_connection_count_limit=0 -o smtpd_client_connection_rate_limit=0 -o receive_override_options=no_unknown_recipient_checks,no_milters -o local_header_rewrite_clients= # smtp-amavis unix - - - - - smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes -o max_use=20 # ##### END OF CONTENT FILTER CUSTOMIZATIONS #####
MySQL *.cf files
- mysql_alias_maps.cf. Zoekt bij de alias de werkelijke user op. Dit kan weer een alias die ook weer opgezocht moet worden. De alias moet actief zijn om gevonden te worden. Deze lookup wordt niet gebruikt in onze configuratie.
- mysql_relay_domains_maps.cf. Zal nooit data terug geven omdat bij alle domeinen het backupmx bit in de database tabel uit staat en het active bit aan staat.
user = postfixadmin password = xxxxxxxx hosts = localhost dbname = postfixadmin #additional_conditions = and backupmx = '1' and active = '1' query = (SELECT domain FROM domain WHERE domain = '%s' AND backupmx = '1' AND active = '0')
- mysql_virtual_alias_maps.cf en mysql_virtual_alias_alias_maps.cf. Zoekt bij de alias de werkelijke user op. Dit kan weer een alias die ook weer opgezocht moet worden. De alias moet actief zijn om gevonden te worden.
user = postfixadmin password = xxxxxxxx hosts = localhost dbname = postfixadmin query = (SELECT goto FROM alias WHERE address = '%s' AND active = '1')
Voorbeeld:
mysql> SELECT goto FROM alias WHERE address = 'secr@hobbynet.hcc.nl' AND active = '1'; +----------------------------+ | goto | +----------------------------+ | secretaris@hobbynet.hcc.nl | +----------------------------+ 1 row in set (0.00 sec) mysql> SELECT goto FROM alias WHERE address = 'secretaris@hobbynet.hcc.nl' AND active = '1'; +--------------------------------+ | goto | +--------------------------------+ | h.e.j.v.d.bussche@kader.hcc.nl | +--------------------------------+ 1 row in set (0.00 sec)
De tweede query is iets ingewikkelder:
user = postfixadmin password = xxxxxxxx hosts = localhost dbname = postfixadmin query = (SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' AND alias.address=concat('%u', '@', alias_domain.target_domain) AND alias.active = 1)
Bijvoorbeeld het opzoeken van het juiste domein bij een alias domein en tevens de echte naam:
mysql> SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = 'kader.hobby.nl' ->AND alias.address=concat('h.e.j.v.d.bussche', '@', alias_domain.target_domain) ->AND alias.active = 1; +----------------------+ | goto | +----------------------+ | 0000103@kader.hcc.nl | +----------------------+ 1 row in set (0.00 sec)
- mysql_virtual_domains_maps.cf. Deze query doet de lookup van een domein. ook hier geld weer dat het domein ingeschakeld moet zijn. Dit is het geval voor alle domeinen waar wij de afhandeling voor doen.
user = postfixadmin password = xxxxxxxx hosts = localhost dbname = postfixadmin #additional_conditions = and backupmx = '0' and active = '1' query= (SELECT description FROM domain WHERE domain ='%s' AND active = '1')
- mysql_virtual_mailbox_maps.cf en mysql_virtual_mailbox_alias_maps.cf. Geheel analoog aan de alias lookup doet deze query de lookup voor de locatie van een mailbox. Het resultaat is een directory.
user = postfixadmin password = xxxxxx hosts = localhost dbname = postfixadmin #additional_conditions = and active = '1' query = (SELECT maildir FROM mailbox WHERE username = '%s' AND active = '1')
en
user = postfixadmin password = xxxxxxxx hosts = localhost dbname = postfixadmin query = (SELECT maildir FROM mailbox, alias_domain WHERE alias_domain.alias_domain = '%d' AND mailbox.username=concat('%u', '@', alias_domain.target_domain ) AND mailbox.active = 1)
Voorbeeld:
mysql> SELECT maildir FROM mailbox, alias_domain WHERE alias_domain.alias_domain = 'kader.hobby.nl' AND mailbox.username=concat('0000103', '@', alias_domain.target_domain ) AND mailbox.active = 1; +-----------------------+ | maildir | +-----------------------+ | kader.hcc.nl/0000103/ | +-----------------------+ 1 row in set (0.00 sec)
- mysql_virtual_mailbox_limit_maps.cf. Deze lookup wordt nog niet gebruikt. Wij leggen nog geen quota op.
recipient_checks.pcre
Hierin staan nog enige beveiligingen tegen SPAM en een vrijkaart voor een paar belangrijke email adressen.
transport
De tranport tabel voorziet in een mapping van email adres naar aflever protocol en next-hop. de protocols zijn in master.cf gedefinieerd. Bij wijzigingen in transport moet altijd postmap /etc/postfix/transport gedraaid worden. Zie ook man transport. Alles voor lists.hobby.nl wordt naar het protocol mailmangestuurd op localhost.
lists.hobby.nl mailman: ksla.nl smtp:[80.100.88.52] ddutch.nl smtp:[80.100.88.52]
Dovecot
Dovecot is een geavanceerde POP en IMAP server met een uitzonderlijk goede support van de schrijver. Niet voor niets dat het pakket zeer veel gebruikt wordt, ook in commerciële situaties. Er is weliswaar al een 2.x tree maar die zit nog niet in de repo's. Voorzichtigheid is geboden omdat nogal wat zal veranderen bij een upgrade naar 2.x. Dovecot maakt gebruik van de zelfde database als Postfix (eigelijk PostfixAdmin). Er zijn twee configuratie bestanden van belang in onze setup.
dovecot.conf
Net zoals bij Postfix kunnen de wijzigingen t.o.v. defdault instellingen opgevraagd wordfen met dovecot -n. Ook is dovecot.conf ruim voorzien van commentaar. Ook online is er veel te vinden in de wiki.
Een greep uit de gewijzigde settings:
- ssl_cert_file: /disk/site/etc/ssl/hobby.nl/hobby.nl.crt. Het Hobbynet wildcard certificaat
- ssl_key_file: /disk/site/etc/ssl/hobby.nl/hobby.nl.key. De bijbehorende key.
- mail_privileged_group: vmail. De eigenaar van zo'n beetje alles...
- mail_location: maildir:~/Maildir. Dovecot kent een duidelijk onderscheid tussen homedir en maildir van een user. Dit is geregeld bediscussieerd op de mailing list. Elke user dient een homedir te hebben, al logt hij nooit interactief in. in die homedir (of ergens anders) staat de maildir. Het formaat de mailstore kan van alles zijn; mbox, maildir++ en in 2.x nog een aantal. In onze setup werken we uitsluitend met maildir++ formaat in de directory /Maildir/ in de homedir.
- mmap_disable: yes, dotlock_use_excl: no, mail_nfs_storage: yes, mail_nfs_index: yes, mbox_write_locks: fcntl dotlock. Een aantal settings dat nodig is als de mailboxen op NFS staan. Dat is bij ons het geval.
- mail_plugins(default): convert autocreate. Declaratie van de te gebruiken plugins. Autocreate zorgt voor het aanmaken van de standard directories als die er nog niet zijn. Convert pikt de oude mailstore op in /disk/mail/convert/<user>/inbox, zet de inhoud in de nieuwe mailstore en renamed de <user> directory in <user-converted>. De *converted directories kunnen weggegooid worden.
- mail_plugins(imap): convert autocreate. De plugins gebruikt in IMAP.
- mail_plugins(pop3): convert autocreate. De plugins gebruikt in POP. Zie onder plugin: in dovecot.conf.
plugin: convert_mail: mbox:/disk/mail/convert/%n autocreate: Trash autocreate2: Sent autocreate3: Drafts autocreate4: Spam autosubscribe: Trash autosubscribe2: Sent autosubscribe3: Drafts autosubscribe4: Spam
- realms: kader.hcc.nl hobby.nl en default_realm: kader.hcc.nl. Deze voorzien erin dat Kderleden met alléén hun lidnummer kunnen inloggen.
- password en user databases. We maken uitsluitend gebruik van users in de PostfixAdmin tabellen. Zie onder dovecot-sql.conf.
passdb: driver: sql args: /etc/dovecot/dovecot-sql.conf userdb: driver: sql args: /etc/dovecot/dovecot-sql.conf
dovecot-sql.conf
Zie uitgebreid commentaar in het dovecot-sql-conf bestand.
password_query = (SELECT username AS user, password, concat('/disk/mail/vmail/', maildir) AS userdb_home, -> concat('maildir:/disk/mail/vmail/', maildir,'Mailir') AS userdb_mail, -> 5000 AS userdb_uid, 5000 AS userdb_gid FROM mailbox -> WHERE username = (SELECT goto FROM alias WHERE address ='%u' AND active = '1') AND active = '1')
Voorbeeld:
mysql> SELECT username AS user, password, concat('/disk/mail/vmail/', maildir) AS userdb_home, -> concat('maildir:/disk/mail/vmail/', maildir,'Maildir') AS userdb_mail, 5000 AS userdb_uid, 5000 AS userdb_gid -> -> FROM mailbox WHERE username = (SELECT goto FROM alias WHERE address ='0000103@kader.hcc.nl' AND active = '1') -> AND active = '1'; +----------------------+-----------+----------------------------------------+-------------------------------------------------------+------------+------------+ | user | password | userdb_home | userdb_mail | userdb_uid | userdb_gid | +----------------------+-----------+----------------------------------------+-------------------------------------------------------+------------+------------+ | 0000103@kader.hcc.nl | NM70w76O/ | /disk/mail/vmail/kader.hcc.nl/0000103/ | maildir:/disk/mail/vmail/kader.hcc.nl/0000103/Maildir | 5000 | 5000 | +----------------------+-----------+----------------------------------------+-------------------------------------------------------+------------+------------+ 1 row in set (0.00 sec)
connect = host=localhost dbname=postfixadmin user=postfixadmin password=xxxxxx user_query = (SELECT concat('/disk/mail/vmail/', maildir) as home, -> concat('maildir:/disk/mail/vmail/', maildir,'Maildir') as mail, 5000 AS uid, 5000 AS gid -> concat('maildir:storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1')
Voorbeeld:
mysql> SELECT concat('/disk/mail/vmail/', maildir) as home, concat('maildir:/disk/mail/vmail/', maildir,'Maildir') as mail, -> 5000 AS uid, 5000 AS gid, concat('maildir:storage=', quota) AS quota FROM mailbox WHERE username = '0000103@kader.hcc.nl'; +----------------------------------------+-------------------------------------------------------+------+------+-------------------+ | home | mail | uid | gid | quota | +----------------------------------------+-------------------------------------------------------+------+------+-------------------+ | /disk/mail/vmail/kader.hcc.nl/0000103/ | maildir:/disk/mail/vmail/kader.hcc.nl/0000103/Maildir | 5000 | 5000 | maildir:storage=0 | +----------------------------------------+-------------------------------------------------------+------+------+-------------------+ 1 row in set (0.00 sec)