T-110.5100 Laboratory Works in Datacommunications Software (4 cr)

Lab 3: Email server



Description of Exercise

In this exercise you will setup an email server with a filter (spamassassin).

Work Tasks

1. Preparation

In this assignment, you need two hosts (lab1 and lab2). Configure the network between the hosts and add the IPv4 addresses and aliases on both computers to the /etc/hosts. Stop daemons that might be listening on the default smtp port.

hosts (5), netstat (8)

2. Installing software

On lab1, verify that the following packages are installed (rpm -qa):

postfix, procmail, spamassassin, and mailx.

On lab2, verify that the following package is installed: mailx.

3. Configuring and testing postfix

Edit postfix main configuration file (main.cf, postconf (5)) on lab1. You have to change following fields:

  • myhostname (from /etc/hosts)
  • mydestination
  • mynetworks (localhost and virtual machines IP block)

Disable ETRN and VRFY commands. Remember to reload postfix configuration (/etc/init.d/postfix).

Configure the sendmail mail on lab2 to send email message to postfix on lab1.  Edit /etc/mail/submit.cf file on lab2 and add value "lab1." to the DS parameter.

Send a message from lab2 to root@lab1 using mail (1). Read the message on lab1 (with mail (1)). See also email message headers. See incoming message information from /var/log/mail.log using tail (1).

3.1 Explain shortly all fields of incoming mail log message (from /var/log/mail.log)
3 p
3.2 Explain shortly all fields of email headers
4 p
3.3
What is purpose of main.cf setting "mydestination"?
2 p
3.4
Why it is really bad idea to set mynetworks broader than necessary (e.g. to 0.0.0.0/1)?
2 p

4. Configuring procmail and spamassassin

Edit /etc/procmailrc (5) and add following line:

:0fw
| /usr/bin/spamassassin

In main.cf, you have to enable procmail with line

/usr/bin/procmail -f- -a "$USER"

to appropriate field (hint: mailbox_command). Remember to reload postfix configuration.

In addition, you might need to assign a home directory for the nobody user:

usermod --home /home/nobody -m nobody

and for this assignment,  stretch permissions to access /var/mail directory:

chmod 1777 /var/mail .

5. Sending and receiving email

Send an email message from lab2 to root@lab1. Read the message on lab1 (with mail -u nobody (1)). See email headers and log messages from mail.log. If you do not see spamassassin headers there is something wrong, go back to previous step and see /var/log/maillog.

5.1
How you can automatically filter spam messages to different folder using procmail? (Hint: correct answer is about three lines without any comments)
2 p
5.2
 Explain briefly additional email headers (compared to step 3.2) 2 p

Final questions and reporting

Include only changed fields from main.cf to your report. Do not copy whole main.cf to your answer. diff (1) is quite useful for finding changed lines. You are required to include the typed commands and their outputs. See Taking notes.

6.1
What is MX record in DNS system?
2 p
6.2
 Explain briefly two ways to make redundant email servers using multiple servers and dns? (hint: see MX records for hut.fi, smtp.hut.fi and tml.hut.fi) 4 p