Configuring Mail services in Linux
In this lab we will examine how to configure mail server
(Sendmail, Dovecot and Spamassassin) services under Linux.
PART 1: Configuring the sendmail Mail Transport Agent (MTA)
to provide Mail server services
Boot your system into the Fedora Linux server VM used in lab 3
to configure DNS and follow the procedure outlined below to
configure your system as a Mail server using the sendmail
MTA.
- Log in as usual and make sure that the Ethernet
(ens33) bridged network interface is enabled.
- Since the sendmail packages are not installed by
default on the system (to verify this type rpm -qa | grep
sendmail at the command prompt), issue the command (as
root)
dnf install sendmail
sendmail-cf to install the latest versions of these
packages.
- Next, using the applet on the top right of the desktop, disable
the Ethernet (ens33) interface (we do this to avoid having your ISP
DNS server appear in the system configuration). Make sure the
Ethernet (ens37) interface is configured with a static IP address
as you did in part 1 of lab 3 (i.e. 192.168.100.10 with mask
255.255.255.0); also make sure that the DNS server address is set
to 192.168.100.10 (i.e. the localhost). Turn off and re-enable the
ens37 interface for the changes to take effect. If necessary, refer
to lab 3 for details on configuring interface settings.
- Make sure that the BIND DNS server configuration is completed
as described in part 2 of lab 3. In addition, using the BIND
configuration GUI, add an MX record entry to the nspdomN.local
forward zone. To do this, right-click the
nspdomN.local zone and select Add – MX
Mail Exchange. In the MXMail Exchange window, enter the
Mail Server Name as F24server.nspdomN.local.
(including the trailing period, N is your unique number) and click
OK. Click Save on the toolbar and
then click Yes to save the changes you have made.
Restart the DNS service by typing systemctl restart
named.service.
- To set up the Mail server we first have to configure the file
/etc/mail/sendmail.mc (we do not want to edit the
configuration file /etc/mail/sendmail.cf directly
since errors in this file can create problems) and then start the
service. Open a terminal window as root, and back up the existing
configuration file by typing
cp /etc/mail/sendmail.mc
/etc/mail/sendmail.mc.bak. Also, back up the
sendmail.cf file using a similar command.
NOTE: Usually, the sendmail
service is configured to start automatically at boot, so you only
have to restart the service when making changes to the
configuration files.
- Using the gedit editor, edit the
/etc/mail/sendmail.mc file and make the following
changes:
- Change the domain name specified in the
LOCAL_DOMAIN directive from
localhost.localdomain to
nspdomN.local (with no trailing period).
- The default configuration file does not allow sendmail
to accept network connections from any other host other than the
local computer. To configure sendmail as a server for
other clients, completely remove the
Addr=127.0.0.1 option of the
DAEMON_OPTIONS directive.
NOTE: If you would like
sendmail to accept connections from the local subnet only,
you need to change the address in the Addr= option
to the IP address of the ens8 interface (i.e.
Addr=192.168.100.10). DO NOT MAKE THIS
CHANGE!
- To have sendmail masquerade other host names on the
network, so that their return address is
[email protected] instead of
[email protected] (this is useful when a
single machine acts as a mail gateway for all machines on the
network and assigns a consistent return address to all outgoing
mail), uncomment (i.e. remove the letters dnl in
front of) the MASQUERADE_AS directive, and change
the name in this directive from mydomain.com to
nspdomN.local. Also uncomment the lines
FEATURE(masquerade_envelope) and
FEATURE(masquerade_entire_domain) and add the
directive
MASQUERADE_DOMAIN(.nspdomN.local)dnl.
- DO NOT MAKE THIS CHANGE AS IT MAY PREVENT SENDMAIL FROM
WORKING – JUST READ IT!
As configured by default,
sendmail accepts e-mail from domains that it cannot
resolve (and that may not exist). To turn this feature off and cut
down the amount of spam you receive, add dnl to
the beginning of the following line:
FEATURE(`accept_unresolvable_domains’)dnl
When this feature is off,
sendmail uses DNS to look up the domains of all e-mails it
receives. If it cannot resolve the domain, it rejects the
e-mail.
NOTE: Please refer to page 743 – 752
in Sobell and chapter 10 of the Fedora 22 system administrator
guide for more details.
- Finally we need to specify which systems the local server
relays e-mail for. To do this edit the file
/etc/mail/access and add the line
Connect:192.168.100.
RELAY
at the end of the file. This line will
allow the server to relay outbound e-mail for all hosts on the
local virtual subnet.
- To enable and start the sendmail service enter the
command systemctl enable sendmail.service followed
by systemctl start sendmail.service.
- The Mail server should now be functional. Test this by opening
a terminal as user student and sending e-mail to
the user itself. Type echo “my sendmail test” |
/sbin/sendmail [email protected]
and then type less
/var/spool/mail/student and scroll to the bottom of the
file to see if the new message has been appended to the student
mail spool file.
WHAT TO SUBMIT: Capture of
system-config-bind GUI on Linux server showing MX
record added. Capture of Linux server terminal window showing
output of echo command above.
2 captures total.