Archive for the tag 'postfix'

Determine which network interface card (NIC)Postfix is running on?

The netstat command allows querying of IP addresses and interfaces that the Postfix daemon is listening. By default, Postfix listens on TCP port 25.

By using the netstat and grep commands for port 25, IP addresses that Postfix are listening to can be found by issuing the following command:

netstat -an | grep :25 | grep tcp

Example:

$ netstat -an | grep :25 | grep tcp
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN

Here, Postfix is only listening on the IP address 127.0.0.1.

In order to list each interface’s assigned IP address, issue the following command as root:

ifconfig -a
SBDavid

Creating the postfix aliases database

Creating the postfix aliases database

Postfix uses a Sendmail-compatible aliases(5) table to redirect mail for local(8) recipients. Typically, this information is kept in two files: in a text file /etc/aliases and in an indexed file /etc/aliases.db. The command “postconf alias_maps” will tell you the exact location of the text file.

root@dell:~# postconf alias_maps
alias_maps = hash:/etc/aliases
root@dell:~#

First, be sure to update the text file with aliases for root, postmaster and “postfix” that forward mail to a real person. Postfix has a sample aliases file /etc/postfix/aliases that you can adapt to local conditions.

/etc/aliases:
root: you
postmaster: root

Note: there should be no whitespace before the “:”.

Finally, build the indexed aliases file with one of the following commands:

# newaliases
# sendmail -bi

Checking Postfix file permission/ownership discrepancies

# postfix check

The first line (postfix check) causes Postfix to report file permission/ownership discrepancies.

# egrep ‘(reject|warning|error|fatal|panic):’ /var/log/maillog

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.

Postfix uses database files for access control

Postfix uses database files for access control, address rewriting and other purposes.

Here is a common example of how Postfix invokes a database:

/etc/postfix/main.cf:
virtual_alias_maps = hash:/etc/postfix/virtual

Whenever you make a change to the main.cf or master.cf file, execute the following command as root in order to refresh a running mail system:

# postfix reload
SBDavid

Postfix configuration files

Postfix configuration files

By default, Postfix configuration files are in /etc/postfix. The two most important files are main.cf and master.cf; these files must be owned by root. Giving someone else write permission to main.cf or master.cf (or to their parent directories) means giving root privileges to that person.

In /etc/postfix/main.cf you will have to set up a minimal number of configuration parameters. 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.

You specify a configuration parameter as:

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

and you use it by putting a “$” character in front of its name:

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

You can use $parameter before it is given a value (that is the second main difference with UNIX shell variables). The Postfix configuration language uses lazy evaluation, and does not look at a parameter value until it is needed at runtime.

Next »