Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux_wiki:configure_a_system_to_forward_all_email_to_a_central_mail_server [2016/10/04 22:58] billdozor [Forward Email: Postfix Setup] |
linux_wiki:configure_a_system_to_forward_all_email_to_a_central_mail_server [2019/05/25 23:50] (current) |
||
---|---|---|---|
Line 8: | Line 8: | ||
**You will be expected to configure a null client only**. (server that forwards mail but does not receive any) | **You will be expected to configure a null client only**. (server that forwards mail but does not receive any) | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Lab Setup ====== | ||
+ | |||
+ | The following virtual machines will be used: | ||
+ | * server1.example.com (192.168.1.150) -> Configure SMTP null client (**on the exam**) | ||
+ | * server2.example.com (192.168.1.151) -> Configure central mail server for client testing (**NOT on the exam**) | ||
---- | ---- | ||
Line 13: | Line 21: | ||
====== Null Client Setup ====== | ====== Null Client Setup ====== | ||
- | A mail null client forwards local email. It does not receive any mail from network sources. | + | **THIS IS ON THE EXAM**: |
+ | |||
+ | **From server1**. | ||
\\ | \\ | ||
Line 29: | Line 39: | ||
\\ | \\ | ||
- | Edit the main configuration | + | Configure postfix parameters |
- | <code bash> | + | * Option A: Use postconf (faster if you have an idea what parameters you need to configure)<code bash># check a setting |
- | vim / | + | postconf relayhost |
- | ## Set the origin | + | # check all settings |
- | myorigin | + | postconf | grep < |
+ | |||
+ | # configure - important | ||
+ | postconf -e ' | ||
+ | |||
+ | # configure - probably already defaults | ||
+ | postconf -e ' | ||
+ | postconf -e ' | ||
+ | postconf -e 'mydomain | ||
+ | </ | ||
+ | * Option B: Edit the main configuration< | ||
# Relayhost to forward mail to | # Relayhost to forward mail to | ||
- | # gmail for testing purposes; exam will provide an IP/hostname of a mail server to use | + | relayhost = [192.168.1.151] |
- | relayhost = [smtp.gmail.com]:587 | + | |
- | # Forward from loopback interfaces | + | # Forward from loopback interfaces |
inet_interfaces = loopback-only | inet_interfaces = loopback-only | ||
- | mynetworks = 127.0.0.0/8 [::1]/128 | ||
# Configure destination as blank, because we aren't delivering mail locally (only forwarding outgoing) | # Configure destination as blank, because we aren't delivering mail locally (only forwarding outgoing) | ||
mydestination = | mydestination = | ||
- | # Prevent postfix from putting mail into mail boxes | + | # Configure domain |
- | local_transport | + | mydomain |
</ | </ | ||
+ | |||
\\ | \\ | ||
- | **NOT ON EXAM** -> Gmail specific: Add gmail settings to the main.cf file | + | Check postfix syntax |
<code bash> | <code bash> | ||
- | vim /etc/postfix/main.cf | + | postfix |
+ | </code> | ||
- | + | \\ | |
- | #### Gmail specific settings - NOT ON THE EXAM #### | + | Restart the service |
- | smtp_use_tls = yes | + | <code bash> |
- | smtp_sasl_auth_enable = yes | + | systemctl restart |
- | smtp_sasl_password_maps = hash:/etc/postfix/ | + | |
- | smtp_tls_CAfile = / | + | |
- | smtp_sasl_security_options = noanonymous | + | |
- | smtp_sasl_tls_security_options = noanonymous | + | |
- | #### End of Gmail specific settings #### | + | |
</ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Postfix Central Mail Server ====== | ||
+ | |||
+ | **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** | ||
\\ | \\ | ||
- | **NOT ON EXAM** -> Gmail specific: Config to sign into a secure SMTP | + | Install postfix |
<code bash> | <code bash> | ||
- | vim /etc/postfix/sasl_passwd | + | yum install |
+ | </code> | ||
- | [smtp.gmail.com]: | + | \\ |
+ | Enable and start postfix | ||
+ | <code bash> | ||
+ | systemctl enable postfix | ||
+ | systemctl start postfix | ||
</ | </ | ||
- | * Replace username and password with actual gmail username and password. | ||
\\ | \\ | ||
- | **NOT ON EXAM** -> Gmail specific: Set restrictive permissions on the sasl file | + | Open the firewall to receive SMTP |
<code bash> | <code bash> | ||
- | chown root: | + | firewall-cmd --permanent --add-service=smtp |
- | chmod 640 / | + | firewall-cmd --reload |
</ | </ | ||
\\ | \\ | ||
- | **NOT ON EXAM** -> Gmail specific: Convert sasl file so postfix can use it | + | Edit the main configuration |
<code bash> | <code bash> | ||
- | postmap | + | #-- vim directly |
+ | vim / | ||
+ | |||
+ | # listening interfaces | ||
+ | inet_interfaces = all | ||
+ | |||
+ | # Accept mail for these domains | ||
+ | mydestination = example.com, | ||
+ | |||
+ | #-- postconf method | ||
+ | |||
+ | # check settings | ||
+ | postconf | grep inet_ | ||
+ | postconf | grep mydestination | ||
+ | |||
+ | # configure | ||
+ | postconf -e ' | ||
+ | postconf -e ' | ||
</ | </ | ||
Line 103: | Line 147: | ||
---- | ---- | ||
- | ====== | + | ====== |
+ | |||
+ | **From server1** | ||
Install a mail client (if not already installed) | Install a mail client (if not already installed) | ||
Line 113: | Line 159: | ||
Send a test message | Send a test message | ||
<code bash> | <code bash> | ||
- | echo "This is the subject body" | mail -s "This is a postfix forward test" | + | echo "Did it work?" | mail -s "This is a postfix forward test" |
</ | </ | ||
Line 120: | Line 166: | ||
<code bash> | <code bash> | ||
tail -f / | tail -f / | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | **From server2** | ||
+ | |||
+ | On the postfix relayhost, check root's mail | ||
+ | <code bash> | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Troubleshooting ====== | ||
+ | |||
+ | On the sending client, to view the mail queue | ||
+ | <code bash> | ||
+ | postqueue -p | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | Flush the sending mail queue after fixing a problem to get rid of stuck messages | ||
+ | <code bash> | ||
+ | postqueue -f | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | If a message is stuck and won't flush, it can be removed | ||
+ | <code bash> | ||
+ | postsuper -d < | ||
+ | </ | ||
+ | * Instead of a single queue_id, you can specify the keyword ' | ||
+ | |||
+ | \\ | ||
+ | On the receiving server, check the maillog for reasons a message did not deliver | ||
+ | <code bash> | ||
+ | tail / | ||
</ | </ | ||
---- | ---- | ||