Postfix Configuration and Administration



Similar documents
Postfix. by Rod Roark

Postfix: Status Quo current development an overview

Configure a Mail Server

ENTERPRISE LINUX NETWORKING SERVICES

Implementing a SPAM and virus scanning mail server using RedHat Linux 8.0

GL275 - ENTERPRISE LINUX NETWORKING SERVICES

CipherMail Gateway Quick Setup Guide

GL-275: Red Hat Linux Network Services. Course Outline. Course Length: 5 days

Implementing a SPAM and virus scanning mail server using RedHat Linux 8.0

Table of Contents. Electronic mail. History of (2) History of (1) history. Basic concepts. Aka (or according to Knuth)

Mail system components. Electronic Mail MRA MUA MSA MAA. David Byers

Table of Contents. Architecture. Organisation. Structure of the organisation. Structure. with sendmail and postfix.

Mail Avenger. David Mazières New York University

QMAIL & SMTP: A Secure Application for an Unsecure Protocol. Orr Dunkelman. orrd@vipe.technion.ac.il. January 27, 2004 SMTP and QMAIL Slide 1

sendmail Cookbook Craig Hunt O'REILLY' Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo

"Charting the Course... Enterprise Linux Networking Services Course Summary

Postfix Anti-Spam Workshop

debops.postfix documentation

Linux Administrator (Advance)

Architecture. with sendmail and postfix. dr. C. P. J. Koymans. Informatics Institute University of Amsterdam. September 30, 2008

Spam fighting with Postfix

Emacs SMTP Library. An Emacs package for sending mail via SMTP. Simon Josefsson, Alex Schroeder

ENTERPRISE LINUX NETWORKING SERVICES

Ficha técnica de curso Código: IFCAD241

Linux MDS Firewall Supplement

Guardian Digital Secure Mail Suite Quick Start Guide

Articles Fighting SPAM in Lotus Domino

Mail agents. Introduction to Internet Mail. Message format (2) Authenticating senders

Lab Tasks 1. Configuring a Slave Name Server 2. Configure rndc for Secure named Control

The Application Layer: DNS

A D M I N I S T R A T O R V 1. 0

Fighting Spam: Tools, Tips, and Techniques

SMTP Servers. Determine if an message should be sent to another machine and automatically send it to that machine using SMTP.

Cannot send Autosupport , error message: Unknown User

Internet Security [1] VU Engin Kirda

Setup Local Mail Server Using Postfix, Dovecot And Squirrelmail On CentOS 6.5/6.4

SMTP Best Practices, Configurations and Troubleshooting on Lotus Domino.

EMB. Basics. Goals of this lab: Prerequisites: LXB, NET, DNS

SpamPanel Reseller Level Manual 1 Last update: September 26, 2014 SpamPanel

Simple Mail Transfer Protocol

SESA Securing with Cisco Security Appliance Parts 1 and 2

FTP: the file transfer protocol

Exchange 2007/2010 Journaling for Cryoserver

NAME smtp zmailer SMTP client transport agent

Linux Network Administration

Frequently Asked Questions

Exchange 2010 Journaling Guide

, SNMP, Securing the Web: SSL

Network Fundamentals Carnegie Mellon University

ICANWK501A Plan, implement and test enterprise communication solutions

Celframe - Easy Linux - Lesson 8 - Server

smtplib SMTP protocol client

A host-based firewall can be used in addition to a network-based firewall to provide multiple layers of protection.

Math SMTP Server Configuration

PostfixAdmin 3.0. Mailserver administration made easy. Christian Boltz

OpenSMTPD : We deliver!

Using RADIUS Agent for Transparent User Identification

Cryoserver Archive Lotus Notes Configuration

How To Write An On A Linux Computer (No Mail) (No ) (For Ahem) (Or Ahem, For Ahem). (For An ) Or Ahem.Org) (Ahem) Or An

Understanding SMTP authentication and securing your IBM Lotus Domino 8 server from spam

Filtering Mail with Milter. David F. Skoll Roaring Penguin Software Inc.

Mail Server Administration

Computer Networks 1 (Mạng Máy Tính 1) Lectured by: Dr. Phạm Trần Vũ MEng. Nguyễn CaoĐạt

Installation Guide For Choic Enterprise Edition

Configuring MailArchiva with Insight Server

. Daniel Zappala. CS 460 Computer Networking Brigham Young University

CS 164 Winter 2009 Term Project Writing an SMTP server and an SMTP client (Receiver-SMTP and Sender-SMTP) Due & Demo Date (Friday, March 13th)

How To Configure Forefront Threat Management Gateway (Forefront) For An Server

IBM i. Networking . Version 7.2

Basic Exchange Setup Guide

Chapter 9 Monitoring System Performance

Architecture and Data Flow Overview. BlackBerry Enterprise Service Version: Quick Reference

Networking Applications

Implementing MDaemon as an Security Gateway to Exchange Server

Internet Technology 2/13/2013

GL254 - RED HAT ENTERPRISE LINUX SYSTEMS ADMINISTRATION III

The basic groups of components are described below. Fig X- 1 shows the relationship between components on a network.

MailStore Server 5.0 Documentation

KASPERSKY LAB. Kaspersky Anti-Virus 5.5 for Linux and FreeBSD Mail Servers ADMINISTRATOR S GUIDE

SPAMfighter SMTP Anti Spam Server

smtp-user-enum User Documentation

Integrated Migration Tool

Journaling Guide for Archive for Exchange 2007

Electronic Mail

Change is Coming: z/os Mail Overview and Futures

COURCE TITLE DURATION LPI-202 Advanced Linux Professional Institute 40 H.

Sonian Getting Started Guide October 2008

Technical Note. ISP Protection against BlackListing. FORTIMAIL Deployment for Outbound Spam Filtering. Rev 2.2

Toll Free: International:

on the RaQ 3. General. server. Services

HP-UX Mailing Services Administrator s Guide

DATA COMMUNICATOIN NETWORKING

My FreeScan Vulnerabilities Report

Transcription:

c 2007 Patrick Koetter & Ralf Hildebrandt state-of-mind LISA 07 Dallas, November 2007 System architecture System metaphor SMTP UUCP QMQP sendmail Postfix SMTP LMTP local pipe virtual transport aliases Figure: The Postfix Router

System architecture System metaphor Postfix is a router It receives messages (packets) from a sender (source) and transports them closer to the recipient (target). Various interfaces are there to handle different protocols. Maps (routing tables) aid to select the appropriate interface and protocol. System architecture System metaphor Postfix is a firewall Check in- and outgoing traffic for basic requirements Enforce restrictions upon messages that do (not) match special criteria

System architecture Design principles Postfix has a modular architecture Each daemon is specialized on one or only a few tasks Each daemon is run with the least priviledge required Daemons maildrop sendmail master anvil smtpd qmqpd pickup cleanup trivial-rewrite incoming hold corrupt resolve tlsmgr qmgr bounce/ defer active deferred local virtual smtp/ lmtp pipe scache Figure: Postfix Daemons

Daemons Most important daemons master The master daemon is the brain of the Postfix mail system. It spawns all other daemons. smtpd The smtpd daemon (server) handles incoming connections. smtp The smtp client handles outgoing connections. qmgr The qmgr-daemon is the heart of the Postfix mail system. It processes and controls all messages in the mail queues. local The local program is Postfix own local delivery agent. It stores messages in mailboxes. Maps Maps help Postfix sort things out Accept or reject message? Who are my recipients? Which interface (read: transport) should I use to send this message? Is the sender permitted to relay?...

Maps Typical map names For envelope sender and envelope recipient addresses aliases virtual generic canonical relocated Maps Typical map names For dedicated transport settings transports

Maps Typical map names For SMTP communication control access Maps Typical map names For content control header_checks body_checks mime_header_checks nested_header_checks (obscure)

Maps Map Types Postfix can handle different map types Linear Maps Indexed Maps Dynamic Maps Network Maps Maps access Map evaluation order localpart+extension@subdomain.domain.tld localpart@subdomain.domain.tld subdomain.domain.tld domain.tld tld localpart+extension@ localpart@ no match found

Maps Virtual and canonical Map evaluation order localpart+extension@subdomain.domain.tld localpart@subdomain.domain.tld localpart+extension localpart @subdomain.domain.tld no match found Maps Transport Map evaluation order localpart+extension@subdomain.domain.tld localpart@subdomain.domain.tld subdomain.domain.tld domain.tld tld * no match found

Configuration files Two configuration files configure Postfix runtime behavior: main.cf holds global configuration options. They will be applied to all instances of a daemon, unless they are overridden in master.cf master.cf defines runtime environment for daemons attached to services. Runtime behavior defined in main.cf may be overridden by setting service specific options. System Preparation SMTP requires a well configured environment. Postfix does not provide the environment. Postfix expects the hosts OS and its services to provide the environment. A well configured host lays the ground for a well functioning Postfix! Hostname proper time DNS resolution DNS entries

Single domain configuration What does Postfix need to provide basic services? Configuring the basics addresses the following questions: Who am I? What s my name? Where am I? Whom am I responsible for? What should I append, if someone wants to send without a domainpart? Which interfaces should I listen on? Whom should I serve? Utilities you don t want to miss! Commands you will use in everyday work with Postfix: postalias postmap postconf postqueue postsuper

How to get help Describe your goal If possible tell how you want to achieve it Give current configuration using postconf -n output Give log excerpts that show your problem Tell what you have tried so far Transport Layer Security LAN Internet mailserver encrypted transport layer mailclient 1122 server certificate Figure: TLS in SMTP communication

Transport Layer Security Why use TLS anway? Privacy Integrity Authenticity Controlled Access Common misconceptions: TLS only protects the communication between two hosts TLS only protects the transport, but not the storage Transport Layer Security Server-Side TLS smtpd_tls_security_level = may smtpd_tls_loglevel = 0 smtpd_tls_received_header = yes smtpd_tls_key_file = /etc/postfix/smtp.key smtpd_tls_cert_file = /etc/postfix/smtp.pem smtpd_tls_capath = /etc/pki/cacerts/ smtpd_tls_dh1024_param_file = /etc/postfix/dh_1024.pem smtpd_tls_dh512_param_file = /etc/postfix/dh_512.pem smtpd_tls_session_cache_database = btree:/var/spool/postfix/smtpd_scache smtpd_tls_session_cache_timeout = 10800s

Transport Layer Security Client-Side TLS smtp_tls_security_level = may smtp_tls_policy_maps = hash:/etc/postfix/tls_policy smtp_tls_loglevel = 0 smtp_tls_key_file = /etc/postfix/smtp.key smtp_tls_cert_file = /etc/postfix/smtp.pem smtp_tls_capath = /etc/pki/cacerts/ smtp_tls_session_cache_database = btree:/var/spool/postfix/smtp_scache smtp_tls_session_cache_timeout = 10800s Relay control Relay control based on static IP-addresses is easy. But how would you deal with dynamic IP-addresses? VPN Seems like a little overkill for one service. SMTP-after-(POP IMAP) / (POP IMAP)-before-SMTP Uses another service to solve the problem and complicates the system. TLS client certificates Are a dream, but there s not enough clients to support it. SMTP AUTH Solves the problem where it arises.

Relay control SMTP AUTH Postfix does not process SMTP AUTH itself. Instead it either relies on the Cyrus SASL authentication framework or on the dovecot authentication service. If Postfix uses Cyrus SASL, it can: offer SMTP AUTH (server-side, smtpd) use SMTP AUTH (client-side, smtp) control usage of the envelope sender Relay control SMTP AUTH The dovecot authentication implementation provides only server-side functionality. Using dovecot Postfix can: offer SMTP AUTH (server-side, smtpd) control usage of the envelope sender

Relay control TLS Client Certificate based relaying Client certificates are not sent by default. smtpd_tls_ask_ccert = yes Three ways to permit relaying based upon client-certificate are available: permit_tls_clientcerts permit_tls_all_clientcerts check_ccert_access type:table Relay control TLS Client Certificate based relaying % openssl x509 -noout -fingerprint -md5 -in \ client_certificates/1_cert.pem MD5 Fingerprint=44:22:00:38:76:87:87:F6:67:27:5C:FB:D8:A5:75:9A smtpd_recipient_restrictions =... permit_mynetworks check_ccert_access hash:/etc/postfix/relay_certificates reject_unauth_destination...

Multi-domain configurations What s in a namespace? Every delivery attempt tries to answer the question: To which host:user should I deliver localpart@domainpart messages? Multi-domain configurations What s in a namespace? The four results in the following namespace variations within Postfix: local domain A local domain has a fixed domainpart and host. Localparts are dynamic and delivery tries to match a system user. virtual alias domain A virtual alias domain has a fixed host. Localparts and domainparts are dynamic and delivery tries to match a system user.

Multi-domain configurations What s in a namespace? virtual mailbox domain A virtual mailbox domain has a fixed host. Localparts and domainparts are dynamic and delivery tries to match a virtual user. relay domain In a relay domain everything is dynamic. At least domainparts and hosts are known and will be sent to a remote host Multi-domain configurations Local Domain A local domain name maps a domain name to local system users.

Multi-domain configurations Virtual alias domains Virtual alias domains map additional domain names to local system users. easily done number of system users is limited (at least on Linux) Multi-domain configurations Virtual mailbox domains Virtual users are in no relation to system users except for the (read: usually one) UID and GID required to write messages to and read messages from a virtual user s mailbox. Virtual mailbox domains use the Postfix virtual daemon for local delivery. It requires special configuration, since virtual has no access to $ENV: Where are mails stored? What s the recipients mailbox? Which mailbox format should be used? Which UID should be used to access the recpients mailbox? Which GID should be used to access the recpients mailbox?

Multi-domain configurations Relay domains A simple relay host configuration answers two questions: Do I need to accept mail for this domain? What s the next hop where I should transport the message to? relay_domains = hash:/etc/postfix/relay_domains Multi-domain configurations Relay domains per-domain transport transport tables are evaluated before any other table! mail.example.com :[gateway.example.com] example.com smtp:bar.example:2025.example.com error:mail for *.example.com is not deliverable

Multi-domain configurations Relay domains dynamic per-recipient transport # LDAP connection parameters version = 3 bind = yes bind_dn = uid=postfix,ou=services,dc=example,dc=com bind_pw = secret # LDAP search and result configuration server_host = ldap://ldap1.example.com ldap://ldap2.example.com search_base = ou=people,dc=example,dc=com query_filter = ( (&(mail=%s)(proxy=true))(maildrop=%s)) result_format = mailstore:[%s] result_attribute = proxyhostname Multi-domain configurations Mixing namespaces What happens if you add more than one domain in mydestination? Why use virtual tables for local domains?

Postfix offers several methods to control message flow: internal methods SMTP smtpd_helo_restrictions communication smtpd_client_restrictions smtpd_sender_restrictions smtpd_recipient_restrictions smtpd_data_restrictions smtpd_end_of_data_restrictions smtpd_etrn_restrictions message content header_checks body_checks mime_header_checks nested_header_checks SMTP communication & message content external methods check_policy content_filter smtpd_proxy_filter none smtpd_milters non_smtpd_milters Restrictions Postfix provides a trigger for each SMTP communication stage The trigger may evaluate one or more restrictions In theory one would evaluate and act upon a restriction at the corresponding SMTP stage, but in practice the earliest moment to evaluate is after the first recipient has been submitted.

Restrictions Moment of evaluation smtpd_delay_reject = no... smtpd_delay_reject = yes... smtpd_client_restrictions, smtpd_helo_restrictions, smtpd_sender_restrictions, smtpd_recipient_restrictions } $ telnet mailserver.example.com 25 220 mailserver.example.com ESMTP Postfix HELO client.example.com 250-mailserver.example.com MAIL FROM:<sender@example.com> 250 Ok RCPT TO:<recipient@example.com> 250 Ok DATA 354 End data with <CR><LF>.<CR><LF> From: "Sender" <sender@example.com> To: "Recipient" <recipient@example.com> Date: Sat, 17 May 2005 15:24:43 +0200 smtpd_client_restrictions smtpd_helo_restrictions smtpd_sender_restrictions smtpd_recipient_restrictions smtpd_data_restrictions Hier ist der Inhalt der Mail.... 250 Ok: queued as 0EAFFE1C65 QUIT 221 Bye smtpd_data_restrictions Figure: Moment of evaluation Restrictions Order of processing The order in which single restrictions are listed is important: Mailclient SMTP smtpd_client_restrictions REJECT restriction a DUNNO REJECT restriction b DUNNO OK, PERMIT REJECT OK, PERMIT default restriction OK, PERMIT smtpd_sender_restrictions REJECT restriction c DUNNO REJECT restriction d DUNNO OK, PERMIT REJECT OK, PERMIT default restriction OK, PERMIT smtpd_..._restrictions REJECT restriction e DUNNO REJECT restriction f DUNNO OK, PERMIT REJECT OK, PERMIT default restriction OK, PERMIT

Policy Services The Postfix smtpd daemon delegates the decision what to do with the message to an external service: Internet mailserver/ mailclient mailserver Postfix policy service smtpd policyd cleanup qmgr pipe local smtp uucp Mailbox tcp Internet mailserver mailserver Figure: Policy Service Policy Services A simple protocol feeds an external service with SMTP communication meta data. Here is an example of all the attributes that the Postfix SMTP server sends in a delegated SMTPD access policy request: Postfix version 2.1 and later: request=smtpd_access_policy protocol_state=rcpt protocol_name=smtp helo_name=some.domain.tld queue_id=8045f2ab23 sender=foo@bar.tld recipient=bar@foo.tld recipient_count=0 client_address=1.2.3.4 client_name=another.domain.tld reverse_client_name=another.domain.tld instance=123.456.7

Policy Services Postfix version 2.2 and later: sasl_method=plain sasl_username=you sasl_sender= size=12345 ccert_subject=solaris9.porcupine.org ccert_issuer=wietse+20venema ccert_fingerprint=c2:9d:f4:87:71:73:73:d9:18:e7:c2:f3:c1:da:6e:04 Policy Services Postfix version 2.3 and later: encryption_protocol=tlsv1/sslv3 encryption_cipher=dhe-rsa-aes256-sha encryption_keysize=256 etrn_domain= [empty line]

Checks Email content Header Body Attachment header Attachment body Attached RFC822 message header Attached RFC822 message body Figure: Internal Mail structure Checks Checks work on content: Header Body MIME Header Check functionality is limited on purpose. Postfix is not a content inspection engine.

Content Filter The Postfix delegates the decision what to with the message to an external filter, either pre- or postqueue. Content Filter Pre- and postqueue filtering Internet Mailserver/ Mailclient Internet Mailserver/ Mailclient Mailserver Mailserver Postfix Filter-Software Postfix Filter-Software before-filter smtpd Filter smtpd with content_filter smtpd without content_filter cleanup after-filter smtpd cleanup Filter qmgr qmgr pipe local smtp pipe local smtp uucp Mailbox tcp uucp Mailbox tcp Internet Internet Mailserver Mailserver Mailserver Mailserver (a) Prequeue filtering (b) Postqueue filtering

Milters smtpd_milters non_smtpd_milters Milters smtpd_milters This is the most recent addition to Postfix. That way you can add the buggyness of Sendmail to Postfix. No really, every milter I touched so far has been crap.

Milters Postfix version 2.3 introduces support for the Sendmail version 8 Milter (mail filter) protocol. This protocol is used by applications that run outside the MTA to inspect SMTP events (CONNECT, DISCONNECT), SMTP commands (HELO, MAIL FROM, etc.) as well as mail content. All this happens before mail is queued. Milters The reason for adding Milter support to Postfix is that there exists a large collection of applications, not only to block unwanted mail, but also to verify authenticity (examples: Domain keys identified mail, SenderID+SPF and Domain keys) or to digitally sign mail (examples: Domain keys identified mail, Domain keys). Having yet another Postfix-specific version of all that software is a poor use of human and system resources. http://sourceforge.net/projects/dkim-milter/ http://sourceforge.net/projects/sid-milter/ http://sourceforge.net/projects/dk-milter/

Milters Postfix version 2.4 implements all the requirements of Sendmail version 8 Milter protocols up to version 4, including message body replacement (body replacement is not available with Postfix version 2.3).