General Information
Configuring postfix.
On the exam, you will be provided all the information of an already configured central SMTP server.
You will be expected to configure a null client only. (server that forwards mail but does not receive any)
The following virtual machines will be used:
THIS IS ON THE EXAM: A mail null client forwards local email. It does not receive any mail from network sources.
From server1.
Install required package
yum install postfix
Enable and start the postfix service
systemctl enable postfix
systemctl start postfix
Configure postfix parameters
# check a setting postconf relayhost # check all settings postconf | grep <keyword> # configure - important postconf -e 'relayhost = [192.168.1.151]' # configure - probably already defaults (or set to localhost) postconf -e 'inet_interfaces = loopback-only' postconf -e 'mydestination =' postconf -e 'mydomain = example.com'
vim /etc/postfix/main.cf # Relayhost to forward mail to relayhost = [192.168.1.151] # Forward from loopback interfaces inet_interfaces = loopback-only # Configure destination as blank, because we aren't delivering mail locally (only forwarding outgoing) mydestination = # Configure domain mydomain = example.com
Check postfix syntax
postfix check
Restart the service
systemctl restart postfix
THIS IS NOT ON THE EXAM: This section setups up a mail server to receive mail in order to test the null client configured previously.
From server2
Install postfix
yum install postfix
Enable and start postfix
systemctl enable postfix
systemctl start postfix
Open the firewall to receive SMTP
firewall-cmd --permanent --add-service=smtp firewall-cmd --reload
Edit the main configuration file
#-- vim directly vim /etc/postfix/main.cf # listening interfaces inet_interfaces = all # Accept mail for these domains mydestination = example.com, server2.example.com, server2 #-- postconf method # check settings postconf | grep inet_ postconf | grep mydestination # configure postconf -e 'inet_interfaces = all' postconf -e 'mydestination = example.com, server2.example.com, server2'
Check postfix syntax
postfix check
Restart the service
systemctl restart postfix
From server1
Install a mail client (if not already installed)
yum install mailx
Send a test message
echo "Did it work?" | mail -s "This is a postfix forward test" root@server2.example.com
Watch the mail log file for status messages
tail -f /var/log/maillog
From server2
On the postfix relayhost, check root's mail
On the sending client, to view the mail queue
postqueue -p
Flush the sending mail queue after fixing a problem to get rid of stuck messages
postqueue -f
If a message is stuck and won't flush, it can be removed
postsuper -d <queue_id>
On the receiving server, check the maillog for reasons a message did not deliver
tail /var/log/maillog