Zum Inhalt springen

Postfix/Grundkonfiguration: Unterschied zwischen den Versionen

Aus Foxwiki
Zeile 96: Zeile 96:
Danach ist die erste Konfiguration von Postfix abgeschlossen und wird in der Datei '''/etc/postfix/main.cf''' hinterlegt.
Danach ist die erste Konfiguration von Postfix abgeschlossen und wird in der Datei '''/etc/postfix/main.cf''' hinterlegt.


=== Postfix configuration files ===
=== Postfix-Konfigurationsdateien ===
By default, Postfix configuration files are in /etc/postfix.  
Standardmäßig befinden sich die Postfix-Konfigurationsdateien in /etc/postfix.  
* The two most important files are [https://www.postfix.org/postconf.5.html main.cf] and [https://www.postfix.org/master.5.html master.cf]<nowiki>; these files must be owned by root.  
* Die beiden wichtigsten Dateien sind [https://www.postfix.org/postconf.5.html main.cf] und [https://www.postfix.org/master.5.html master.cf]<nowiki>; diese Dateien müssen root gehören.  
* Giving someone else write permission to </nowiki>[https://www.postfix.org/postconf.5.html main.cf] or [https://www.postfix.org/master.5.html master.cf] (or to their parent directories) means giving root privileges to that person.
* Wenn Sie jemandem Schreibrechte für </nowiki>[https://www.postfix.org/postconf.5.html main.cf] oder [https://www.postfix.org/master.5.html master.cf] (oder für die übergeordneten Verzeichnisse) geben, bedeutet das, dass Sie dieser Person root-Rechte geben.


In /etc/postfix/[https://www.postfix.org/postconf.5.html main.cf] you will have to set up a minimal number of configuration parameters.  
In /etc/postfix/[https://www.postfix.org/postconf.5.html main.cf] müssen Sie eine minimale Anzahl von Konfigurationsparametern einrichten.  
* Postfix configuration parameters resemble shell variables, with two important differences: the first one is that Postfix does not know about quotes like the UNIX shell does.
* Postfix-Konfigurationsparameter ähneln Shell-Variablen, mit zwei wichtigen Unterschieden: Der erste ist, dass Postfix keine Anführungszeichen kennt, wie die UNIX-Shell.


You specify a configuration parameter as:
Sie geben einen Konfigurationsparameter wie folgt an:


  /etc/postfix/[https://www.postfix.org/postconf.5.html main.cf]:
  /etc/postfix/[https://www.postfix.org/postconf.5.html main.cf]:
  parameter = value
  parameter = wert


and you use it by putting a "$" character in front of its name:
und Sie verwenden ihn, indem Sie ein "$"-Zeichen vor seinen Namen setzen:


  /etc/postfix/[https://www.postfix.org/postconf.5.html main.cf]:
  /etc/postfix/[https://www.postfix.org/postconf.5.html main.cf]:
  other_parameter = $parameter
  anderer_parameter = $parameter


You can use $parameter before it is given a value (that is the second main difference with UNIX shell variables).  
Sie können $parameter verwenden, bevor ihm ein Wert zugewiesen wird (das ist der zweite wesentliche Unterschied zu UNIX-Shell-Variablen).  
* The Postfix configuration language uses lazy evaluation, and does not look at a parameter value until it is needed at runtime.
* Die Postfix-Konfigurationssprache verwendet eine "lazy evaluation", d.h. sie prüft einen Parameterwert erst, wenn er zur Laufzeit benötigt wird.


Postfix uses database files for access control, address rewriting and other purposes.  
Postfix verwendet Datenbankdateien für die Zugriffskontrolle, das Umschreiben von Adressen und andere Zwecke.  
* The [https://www.postfix.org/DATABASE_README.html DATABASE_README] file gives an introduction to how Postfix works with Berkeley DB, LDAP or SQL and other types.  
* Die Datei [https://www.postfix.org/DATABASE_README.html DATABASE_README] gibt eine Einführung, wie Postfix mit Berkeley DB, LDAP oder SQL und anderen Typen arbeitet.  
* Here is a common example of how Postfix invokes a database:
* Hier ist ein allgemeines Beispiel dafür, wie Postfix eine Datenbank aufruft:


  /etc/postfix/[https://www.postfix.org/postconf.5.html main.cf]:
  /etc/postfix/[https://www.postfix.org/postconf.5.html main.cf]:
  [https://www.postfix.org/postconf.5.html#virtual_alias_maps virtual_alias_maps] = [https://www.postfix.org/DATABASE_README.html#types hash]:/etc/postfix/virtual
  [https://www.postfix.org/postconf.5.html#virtual_alias_maps virtual_alias_maps] = [https://www.postfix.org/DATABASE_README.html#types hash]:/etc/postfix/virtual


Whenever you make a change to the [https://www.postfix.org/postconf.5.html main.cf] or [https://www.postfix.org/master.5.html master.cf] file, execute the following command as root in order to refresh a running mail system:
Immer wenn Sie eine Änderung an der Datei [https://www.postfix.org/postconf.5.html main.cf] oder [https://www.postfix.org/master.5.html master.cf] vornehmen, führen Sie den folgenden Befehl als root aus, um ein laufendes Mailsystem zu aktualisieren:


  <nowiki># postfix reload</nowiki>
  <nowiki># postfix reload</nowiki>

Version vom 4. September 2022, 14:39 Uhr

Einführung

Postfix hat mehrere hundert Konfigurationsparameter, die über die Datei main.cf gesteuert werden.

  • Glücklicherweise haben alle Parameter sinnvolle Standardwerte.
  • In vielen Fällen müssen Sie nur zwei oder drei Parameter konfigurieren, bevor Sie mit dem Mailsystem spielen können.
  • Hier eine kurze Einführung in die Syntax: * Postfix-Konfigurationsdateien

Der folgende Text geht davon aus, dass Sie Postfix bereits auf Ihrem System installiert haben, entweder indem Sie den Quellcode selbst kompiliert haben (wie in der Datei INSTALL beschrieben) oder indem Sie eine bereits kompilierte Version installiert haben.

Dieses Dokument behandelt die grundlegende Konfiguration von Postfix.

  • Informationen zur Konfiguration von Postfix für bestimmte Anwendungen wie Mailhub, Firewall oder Einwahlclient finden Sie in der Datei STANDARD_CONFIGURATION_README.
  • Gehen Sie aber erst dorthin, wenn Sie sich mit dem unten dargestellten Material vertraut gemacht haben.

Die ersten Parameter, die von Interesse sind, geben die Identität und die Rolle des Rechners im Netzwerk an. * Welcher Domänenname soll im Postausgang verwendet werden?

Die Standardwerte für viele andere Konfigurationsparameter werden von diesen abgeleitet.

Der nächste interessante Parameter steuert die Menge der an den lokalen Postmaster gesendeten Post: * Welche Probleme sollen dem Postmaster gemeldet werden

Vergewissern Sie sich, dass Sie die folgenden Einstellungen korrekt vornehmen, wenn Sie hinter einem Proxy oder Netzwerkadressenübersetzer sitzen und einen Backup-MX-Host für eine andere Domäne betreiben: * Proxy/NAT externe Netzwerkadressen

Postfix-Daemon-Prozesse laufen im Hintergrund und protokollieren Probleme und normale Aktivitäten an den Syslog-Daemon.

Wenn Ihr Rechner ungewöhnliche Sicherheitsanforderungen hat, sollten Sie Postfix-Daemon-Prozesse in einer Chroot-Umgebung ausführen. * Postfix-Daemon-Prozesse in einer chroot-Umgebung laufen lassen

Wenn Sie Postfix auf einer virtuellen Netzwerkschnittstelle ausführen oder wenn Ihr Rechner andere Mailer auf virtuellen Schnittstellen betreibt, müssen Sie auch die anderen hier aufgeführten Parameter beachten: * Mein eigener Hostname

Grundkonfiguration

Nach der Installation folgt die Grundkonfiguration

  • Standardwerte übernehmen, bei Fragen, die hier nicht angesprochen werden

Typ der Konfiguration / Einsatzszenario

Typ Beschreibung
Keine Konfiguration Aktuelle Konfiguration unverändert lassen
Internet Site Mail wird empfangen und verschickt (Standard).
  • Echter Mailserver mit fester IP-Adresse, z.B.
  • Root-Server, E-Mails werden direkt via SMTP versandt und empfangen.
Smarthost Wie Internet Site, aber Mail wird nicht direkt an den entfernten Server zugestellt, sondern über einen anderen Server (etwa beim ISP) geleitet.
  • Mailserver mit dynamischer IP-Adresse, die sonst sehr oft als potentielle Spam- oder Virenversender blockiert werden.
  • E-Mails werden direkt mittels SMTP oder über ein Hilfsprogramm wie Fetchmail empfangen.
  • Ausgehende E-Mails werden über einen Smarthost versandt-
Satellite System Keine Mail wird empfangen, alle ausgehende Mail über einen Smarthost (s.o.) verschickt.
  • Mail durch Admin-Skripte oder Webapplikationen verschicken lassen.
  • Alle E-Mails werden zur Zustellung einer anderen Maschine, genannt »Smarthost«, übergeben.
Local only Mail wird lokal auf dem Rechner zugestellt, es wird keine Mail von außen empfangen bzw.
  • nach außen geschickt.
  • Wie Satellite System, aber die Mail soll direkt auf demselben System gelesen werden.
  • Es werden nur E-Mails für lokale Benutzer zugestellt.
  • Ohne Netzwerkzugang.

Grundkonfiguration wiederholen

# dpkg-reconfigure postfix

Wohin soll die Mail für root gehen?

Hier sollte man entweder den Benutzernamen des Admins eintragen oder seine gültige E-Mail-Adresse.

Mailname

  • Dies ist der Name des Rechners, der jeder ausgehenden Mail als Absender-Domain hinzugefügt wird.
  • In den meisten Fällen sollte man einfach den Hostnamen als Mailnamen akzeptieren, außer man ist im Besitz eines geeigneteren Domain-Namens.

SMTP relay host?

  • Mailserver des Anbieters z.B.
    • smtp.mailanbieter.de

Für welche weiteren Rechner möchten Sie Mails akzeptieren?

Wenn man den Mailserver für bestimmte Domains betreibt, die hier noch nicht aufgelistet werden, muss man diese ergänzen.

Local Networks

  • Hier trägt man ein, welche Maschinen Mail über diesen Server verschicken dürfen.
  • Es ist wichtig, dass man seinen Server hier nicht Unbekannten zur Verfügung stellt, die darüber dann Spam oder Viren verschicken können (Open Relay).
  • Als Vorgabe steht dort 127.0.0.0/8, was bedeutet, dass man nur vom lokalen Rechner aus Mails versenden darf.
  • Wer seinen Mailserver aus dem ganzen LAN zum Versand nutzen will, sollte hier zusätzlich sein eigenes Netz eintragen:
127.0.0.0/8, 192.168.1.0/24

Wer seinen Server, bspw.

  • einen Root-Server, über das Internet nutzen will, sollte hier auf keinen Fall weite Adressbereiche erlauben, sondern für den Versand stattdessen eine Postfix:Authentifizierung verlangen.
Hinweis
Je nach Version sehen diese Fragen etwas anders aus. 
Der wichtigste Punkt ist immer der SMTP-Server, wenn man Smarthost oder Satellite gewählt hat. 

Danach ist die erste Konfiguration von Postfix abgeschlossen und wird in der Datei /etc/postfix/main.cf hinterlegt.

Postfix-Konfigurationsdateien

Standardmäßig befinden sich die Postfix-Konfigurationsdateien in /etc/postfix.

  • Die beiden wichtigsten Dateien sind main.cf und master.cf; diese Dateien müssen root gehören. * Wenn Sie jemandem Schreibrechte für main.cf oder master.cf (oder für die übergeordneten Verzeichnisse) geben, bedeutet das, dass Sie dieser Person root-Rechte geben.

In /etc/postfix/main.cf müssen Sie eine minimale Anzahl von Konfigurationsparametern einrichten.

  • Postfix-Konfigurationsparameter ähneln Shell-Variablen, mit zwei wichtigen Unterschieden: Der erste ist, dass Postfix keine Anführungszeichen kennt, wie die UNIX-Shell.

Sie geben einen Konfigurationsparameter wie folgt an:

/etc/postfix/main.cf:
parameter = wert

und Sie verwenden ihn, indem Sie ein "$"-Zeichen vor seinen Namen setzen:

/etc/postfix/main.cf:
anderer_parameter = $parameter

Sie können $parameter verwenden, bevor ihm ein Wert zugewiesen wird (das ist der zweite wesentliche Unterschied zu UNIX-Shell-Variablen).

  • Die Postfix-Konfigurationssprache verwendet eine "lazy evaluation", d.h. sie prüft einen Parameterwert erst, wenn er zur Laufzeit benötigt wird.

Postfix verwendet Datenbankdateien für die Zugriffskontrolle, das Umschreiben von Adressen und andere Zwecke.

  • Die Datei DATABASE_README gibt eine Einführung, wie Postfix mit Berkeley DB, LDAP oder SQL und anderen Typen arbeitet.
  • Hier ist ein allgemeines Beispiel dafür, wie Postfix eine Datenbank aufruft:
/etc/postfix/main.cf:
virtual_alias_maps = hash:/etc/postfix/virtual

Immer wenn Sie eine Änderung an der Datei main.cf oder master.cf vornehmen, führen Sie den folgenden Befehl als root aus, um ein laufendes Mailsystem zu aktualisieren:

# postfix reload

What domain name to use in outbound mail

The myorigin parameter specifies the domain that appears in mail that is posted on this machine.

  • The default is to use the local machine name, $myhostname, which defaults to the name of the machine.
  • Unless you are running a really small site, you probably want to change that into $mydomain, which defaults to the parent domain of the machine name.

For the sake of consistency between sender and recipient addresses, myorigin also specifies the domain name that is appended to an unqualified recipient address.

Examples (specify only one of the following):

/etc/postfix/main.cf:
myorigin = $myhostname (default: send mail as "user@$myhostname")
myorigin = $mydomain   (probably desirable: "user@$mydomain")

What domains to receive mail for

The mydestination parameter specifies what domains this machine will deliver locally, instead of forwarding to another machine.

You can specify zero or more domain names, "/file/name" patterns and/or "type:table" lookup tables (such as hash:, btree:, nis:, ldap:, or mysql:), separated by whitespace and/or commas.

  • A "/file/name" pattern is replaced by its contents; "type:table" requests that a table lookup is done and merely tests for existence: the lookup result is ignored.

IMPORTANT: If your machine is a mail server for its entire domain, you must list $mydomain as well.

Example 1: default setting.

/etc/postfix/main.cf:
mydestination = $myhostname localhost.$mydomain localhost

Example 2: domain-wide mail server.

/etc/postfix/main.cf:
mydestination = $myhostname localhost.$mydomain localhost $mydomain

Example 3: host with multiple DNS A records.

/etc/postfix/main.cf:
mydestination = $myhostname localhost.$mydomain localhost
    www.$mydomain ftp.$mydomain

Caution: in order to avoid mail delivery loops, you must list all hostnames of the machine, including $myhostname, and localhost.$mydomain.

What clients to relay mail from

By default, Postfix will forward mail from clients in authorized network blocks to any destination.

  • Authorized networks are defined with the mynetworks configuration parameter.
  • The current default is to authorize the local machine only.
  • Prior to Postfix 3.0, the default was to authorize all clients in the IP subnetworks that the local machine is attached to.

Postfix can also be configured to relay mail from "mobile" clients that send mail from outside an authorized network block.

IMPORTANT: If your machine is connected to a wide area network then the "mynetworks_style = subnet" setting may be too friendly.

Examples (specify only one of the following):

/etc/postfix/main.cf:
mynetworks_style = subnet  (not safe on a wide area network)
mynetworks_style = host    (authorize local machine only)
mynetworks = 127.0.0.0/8   (authorize local machine only)
mynetworks = 127.0.0.0/8 168.100.189.2/32 (authorize local machine)
mynetworks = 127.0.0.0/8 168.100.189.2/28 (authorize local networks)

You can specify the trusted networks in the main.cf file, or you can let Postfix do the work for you.

  • The default is to let Postfix do the work.
  • The result depends on the mynetworks_style parameter value. * Specify "mynetworks_style = host" (the default when compatibility_level ≥ 2) when Postfix should forward mail from only the local machine.
  • Specify "mynetworks_style = subnet" (the default when compatibility_level < 2) when Postfix should forward mail from SMTP clients in the same IP subnetworks as the local machine.
  • On Linux, this works correctly only with interfaces specified with the "ifconfig" or "ip" command.
  • Specify "mynetworks_style = class" when Postfix should forward mail from SMTP clients in the same IP class A/B/C networks as the local machine.
  • Don't do this with a dialup site - it would cause Postfix to "trust" your entire provider's network.
  • Instead, specify an explicit mynetworks list by hand, as described below.

Alternatively, you can specify the mynetworks list by hand, in which case Postfix ignores the mynetworks_style setting.

  • To specify the list of trusted networks by hand, specify network blocks in CIDR (network/mask) notation, for example:
/etc/postfix/main.cf:
mynetworks = 168.100.189.0/28, 127.0.0.0/8

You can also specify the absolute pathname of a pattern file instead of listing the patterns in the main.cf file.

What destinations to relay mail to

By default, Postfix will forward mail from strangers (clients outside authorized networks) to authorized remote destinations only.

  • Authorized remote destinations are defined with the relay_domains configuration parameter.
  • The default is to authorize all domains (and subdomains) of the domains listed with the mydestination parameter.

Examples (specify only one of the following):

/etc/postfix/main.cf:
relay_domains = $mydestination (default)
relay_domains =           (safe: never forward mail from strangers)
relay_domains = $mydomain (forward mail to my domain and subdomains)

What delivery method: direct or indirect

By default, Postfix tries to deliver mail directly to the Internet.

  • Depending on your local conditions this may not be possible or desirable.
  • For example, your system may be turned off outside office hours, it may be behind a firewall, or it may be connected via a provider who does not allow direct mail to the Internet.
  • In those cases you need to configure Postfix to deliver mail indirectly via a relay host.

Examples (specify only one of the following):

/etc/postfix/main.cf:
relayhost =                   (default: direct delivery to Internet)
relayhost = $mydomain         (deliver via local mailhub)
relayhost = [mail.$mydomain]  (deliver via local mailhub)
relayhost = [mail.isp.tld]    (deliver via provider mailhub)

The form enclosed with [] eliminates DNS MX lookups.

  • Don't worry if you don't know what that means.
  • Just be sure to specify the [] around the mailhub hostname that your ISP gave to you, otherwise mail may be mis-delivered.

The STANDARD_CONFIGURATION_README file has more hints and tips for firewalled and/or dial-up networks.

What trouble to report to the postmaster

You should set up a postmaster alias in the aliases(5) table that directs mail to a human person.

  • The postmaster address is required to exist, so that people can report mail delivery problems.
  • While you're updating the aliases(5) table, be sure to direct mail for the super-user to a human person too.
/etc/aliases:
postmaster: you
root: you

Execute the command "newaliases" after changing the aliases file.

  • Instead of /etc/aliases, your alias file may be located elsewhere.
  • Use the command "postconf alias_maps" to find out.

The Postfix system reports problems to the postmaster alias.

  • You may not be interested in all types of trouble reports, so this reporting mechanism is configurable.
  • The default is to report only serious problems (resource, software) to postmaster:

Default setting:

/etc/postfix/main.cf:
notify_classes = resource, software

The meaning of the classes is as follows:

bounce
Inform the postmaster of undeliverable mail.
  • Either send the postmaster a copy of undeliverable mail that is returned to the sender, or send a transcript of the SMTP session when Postfix rejected mail.
  • For privacy reasons, the postmaster copy of undeliverable mail is truncated after the original message headers.
  • This implies "2bounce" (see below).
  • See also the luser_relay feature.
  • The notification is sent to the address specified with the bounce_notice_recipient configuration parameter (default: postmaster).
2bounce
When Postfix is unable to return undeliverable mail to the sender, send it to the postmaster instead (without truncating the message after the primary headers).
  • The notification is sent to the address specified with the 2bounce_notice_recipient configuration parameter (default: postmaster).
delay
Inform the postmaster of delayed mail.
  • In this case, the postmaster receives message headers only.
  • The notification is sent to the address specified with the delay_notice_recipient configuration parameter (default: postmaster).
policy
Inform the postmaster of client requests that were rejected because of (UCE) policy restrictions.
  • The postmaster receives a transcript of the SMTP session.
  • The notification is sent to the address specified with the error_notice_recipient configuration parameter (default: postmaster).
protocol
Inform the postmaster of protocol errors (client or server side) or attempts by a client to execute unimplemented commands.
  • The postmaster receives a transcript of the SMTP session.
  • The notification is sent to the address specified with the error_notice_recipient configuration parameter (default: postmaster).
resource
Inform the postmaster of mail not delivered due to resource problems (for example, queue file write errors).
  • The notification is sent to the address specified with the error_notice_recipient configuration parameter (default: postmaster).
software
Inform the postmaster of mail not delivered due to software problems.
  • The notification is sent to the address specified with the error_notice_recipient configuration parameter (default: postmaster).

Proxy/NAT external network addresses

Some mail servers are connected to the Internet via a network address translator (NAT) or proxy.

  • This means that systems on the Internet connect to the address of the NAT or proxy, instead of connecting to the network address of the mail server.
  • The NAT or proxy forwards the connection to the network address of the mail server, but Postfix does not know this.

If you run a Postfix server behind a proxy or NAT, you need to configure the proxy_interfaces parameter and specify all the external proxy or NAT addresses that Postfix receives mail on.

  • You may specify symbolic hostnames instead of network addresses.

IMPORTANT: You must specify your proxy/NAT external addresses when your system is a backup MX host for other domains, otherwise mail delivery loops will happen when the primary MX host is down.

Example: host behind NAT box running a backup MX host.

/etc/postfix/main.cf:
proxy_interfaces = 1.2.3.4 (the proxy/NAT external network address)

What you need to know about Postfix logging

Postfix daemon processes run in the background, and log problems and normal activity to the syslog daemon.

  • The syslogd process sorts events by class and severity, and appends them to logfiles.
  • The logging classes, levels and logfile names are usually specified in /etc/syslog.conf.
  • At the very least you need something like:
/etc/syslog.conf:
mail.err                                    /dev/console
mail.debug                                  /var/log/maillog

After changing the syslog.conf file, send a "HUP" signal to the syslogd process.

IMPORTANT: many syslogd implementations will not create files.

  • You must create files before (re)starting syslogd.

IMPORTANT: on Linux you need to put a "-" character before the pathname, e.g., -/var/log/maillog, otherwise the syslogd process will use more system resources than Postfix.

Hopefully, the number of problems will be small, but it is a good idea to run every night before the syslog files are rotated:

# postfix check # egrep '(reject|warning|error|fatal|panic):' /some/log/file* The first line (postfix check) causes Postfix to report file permission/ownership discrepancies.

  • The second line looks for problem reports from the mail software, and reports how effective the relay and junk mail access blocks are.
  • This may produce a lot of output.
  • You will want to apply some postprocessing to eliminate uninteresting information.

The DEBUG_README document describes the meaning of the "warning" etc.

  • labels in Postfix logging.

Running Postfix daemon processes chrooted

Postfix daemon processes can be configured (via the master.cf file) to run in a chroot jail.

  • The processes run at a fixed low privilege and with file system access limited to the Postfix queue directories (/var/spool/postfix).
  • This provides a significant barrier against intrusion.
  • The barrier is not impenetrable (chroot limits file system access only), but every little bit helps.

With the exception of Postfix daemons that deliver mail locally and/or that execute non-Postfix commands, every Postfix daemon can run chrooted.

Sites with high security requirements should consider to chroot all daemons that talk to the network: the smtp(8) and smtpd(8) processes, and perhaps also the lmtp(8) client.

  • The author's own porcupine.org mail server runs all daemons chrooted that can be chrooted.

The default /etc/postfix/master.cf file specifies that no Postfix daemon runs chrooted.

  • In order to enable chroot operation, edit the file /etc/postfix/master.cf, and follow instructions in the file.
  • When you're finished, execute "postfix reload" to make the change effective.

Note that a chrooted daemon resolves all filenames relative to the Postfix queue directory (/var/spool/postfix).

  • For successful use of a chroot jail, most UNIX systems require you to bring in some files or device nodes.
  • The examples/chroot-setup directory in the source code distribution has a collection of scripts that help you set up Postfix chroot environments on different operating systems.

Additionally, you almost certainly need to configure syslogd so that it listens on a socket inside the Postfix queue directory.

  • Examples of syslogd command line options that achieve this for specific systems:

FreeBSD: syslogd -l /var/spool/postfix/var/run/log

Linux, OpenBSD: syslogd -a /var/spool/postfix/dev/log

My own hostname

The myhostname parameter specifies the fully-qualified domain name of the machine running the Postfix system. $myhostname appears as the default value in many other Postfix configuration parameters.

By default, myhostname is set to the local machine name.

  • If your local machine name is not in fully-qualified domain name form, or if you run Postfix on a virtual interface, you will have to specify the fully-qualified domain name that the mail system should use.

Alternatively, if you specify mydomain in main.cf, then Postfix will use its value to generate a fully-qualified default value for the myhostname parameter.

Examples (specify only one of the following):

/etc/postfix/main.cf:
myhostname = host.local.domain (machine name is not FQDN)
myhostname = host.virtual.domain (virtual interface)
myhostname = virtual.domain (virtual interface)

My own domain name

The mydomain parameter specifies the parent domain of $myhostname.

  • By default, it is derived from $myhostname by stripping off the first part (unless the result would be a top-level domain).

Conversely, if you specify mydomain in main.cf, then Postfix will use its value to generate a fully-qualified default value for the myhostname parameter.

Examples (specify only one of the following):

/etc/postfix/main.cf:
mydomain = local.domain
mydomain = virtual.domain (virtual interface)

My own network addresses

The inet_interfaces parameter specifies all network interface addresses that the Postfix system should listen on; mail addressed to "user@[network address]" will be delivered locally, as if it is addressed to a domain listed in $mydestination.

You can override the inet_interfaces setting in the Postfix master.cf file by prepending an IP address to a server name.

The default is to listen on all active interfaces.

  • If you run mailers on virtual interfaces, you will have to specify what interfaces to listen on.

IMPORTANT: If you run MTAs on virtual interfaces you must specify explicit inet_interfaces values for the MTA that receives mail for the machine itself: this MTA should never listen on the virtual interfaces or you would have a mailer loop when a virtual MTA is down.

Example: default setting.

/etc/postfix/main.cf:
inet_interfaces = all

Example: host running one or more virtual mailers.

  • For each Postfix instance, specify only one of the following.
/etc/postfix/main.cf:
inet_interfaces = virtual.host.tld         (virtual Postfix)
inet_interfaces = $myhostname localhost... (non-virtual Postfix)

Note: you need to stop and start Postfix after changing this parameter.