Mail Server (Demo)
Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or
Already have an account? Sign In »

Video Transcription
00:00
>> Hey Cyberians and welcome back to
00:00
the Linux plus course here at Cybrary.
00:00
I'm your instructor Rob Gilles.
00:00
In today's lesson we are going to
00:00
be discussing mail servers.
00:00
Upon completion of this lesson,
00:00
you are going to be able to understand
00:00
the importance of mail servers.
00:00
We'll talk about how mail servers
00:00
work in Linux and then we're going to
00:00
install the Postfix package on both CentOS and Ubuntu.
00:00
Earlier in this module, we covered
00:00
monitoring and we talked about how
00:00
monitoring often we alert systems administrators.
00:00
The most common way to do this is via email,
00:00
so a lot of times
00:00
mail software packages are also
00:00
installed on monitoring servers.
00:00
Of course, organizations need
00:00
the email for its common purpose,
00:00
which is just to communicate both
00:00
inside and outside of the company.
00:00
One of the major functions of Linux is to act as what's
00:00
called a mail transfer agent or MTA.
00:00
A mail transfer agent does exactly what it sounds like.
00:00
It transfers email and it transfers email
00:00
from a client system to a recipient system.
00:00
The MTA uses the Simple Mail Transfer Protocol,
00:00
or SMTP, as the common protocol
00:00
that's used to send email via the Internet.
00:00
Really SMTP is used to relay
00:00
email between mail servers and clients.
00:00
Remember, SMTP runs on Port 25,
00:00
that is likely to be on the exam.
00:00
Port 25 for SMTP, remember that.
00:00
Now just a brief overview of how this all look so you
00:00
can wrap your head around MTAs and everything else.
00:00
Generally, what happens to
00:00
start is that a client wants to send
00:00
an email and they're going to be
00:00
>> using a Mail User Agent.
00:00
>> This could be something like Outlook or
00:00
Thunderbird or one of
00:00
the other male packages that are out there.
00:00
After they click the email Send button,
00:00
it's going to send that to a mail submission agent.
00:00
The mail submission agent looks at this and
00:00
sends that to the MTA,
00:00
the mail transfer agent.
00:00
The mail transfer agent goes,
00:00
what does this mail exchange record say? The MX.
00:00
The MX record is the DNS record for
00:00
the mail servers and it goes
00:00
is this our local mail server?
00:00
This is a local recipient
00:00
and then when it does is it sends it
00:00
to the mail delivery agent and then
00:00
that sends it on to the recipient.
00:00
They open that using
00:00
their mail user agent to read the email.
00:00
However, if the recipient is not local,
00:00
the mail gets routed to another
00:00
>> MTA based on the record,
00:00
>> and so on and so on until it hits
00:00
the local MTA that manages that MX record.
00:00
With that, let's go ahead and move on and
00:00
install Postfix with some demo time.
00:00
Here we are on our CentOS environment
00:00
and to install Postfix,
00:00
we just do a dnf install postfix.
00:00
This is actually installed because I
00:00
cheated in this before we got started.
00:00
What we can do is we can do a systemctl
00:00
enable dash dash now for postfix,
00:00
and this will start and enable
00:00
Postfix for us and we're good to go.
00:00
Now we can see that the status is done on this.
00:00
We do a systemctl status,
00:00
we can see that Postfix is installed and running.
00:00
Just saving ourselves a little time here, folks.
00:00
Now let's take a look at the file,
00:00
we'll do an /etc/postfix/main.cf.
00:00
This is the main configuration file for Postfix,
00:00
and that's a lot of information.
00:00
First to look at this, let's just do this.
00:00
We're going to do a grep minus
00:00
v for the pound sign because we don't really
00:00
need to see all the comments
00:00
just to get started and we'll
00:00
do that on postfix/main.cf.
00:00
We're going to pipe that to less
00:00
just so that we can see all the information here.
00:00
There we go. What we're going to see in
00:00
this configuration file is a couple of things.
00:00
One of the most important thing is probably is
00:00
we're going to see the queue directory here.
00:00
This is the mail queue, this is
00:00
where you're going to find mail queued up
00:00
for delivery or for analysis by the MTA,
00:00
the command directory where
00:00
Postfix actually lives in user sbin,
00:00
and then we have a daemon directory
00:00
>> and a data directory.
00:00
>> If we scroll down here a little bit,
00:00
what we'll see is where the certificates are
00:00
setup because we have to use certificate files,
00:00
so make sure that this is encrypted.
00:00
smtp_tls_cert_file is here as well as the key,
00:00
the security level, and a bunch
00:00
of other cert information as well.
00:00
Now let's actually go back into the file.
00:00
We're going to go ahead and use
00:00
vim to look at it and we'll just
00:00
navigate around as best we can and
00:00
try and avoid creating too many comments.
00:00
If we are configuring the server for real,
00:00
we would need to set the host name and domain in
00:00
the config file by uncommenting a few lines.
00:00
Let's turn on the numbers in here by
00:00
doing Escape colon set number.
00:00
What I'm actually going to do is go to the Line
00:00
94 and we're going to see Line 94 and Line 102.
00:00
The way that I can do that on
00:00
my keyboard is by typing in 94
00:00
and then capital G. That'll take us the Line 94,
00:00
which is where we are right now.
00:00
If we were to go ahead and
00:00
>> configure the server for real,
00:00
>> we'd set the host name here
00:00
and then down here we would set the domain.
00:00
We're just going to use these values just for
00:00
our kicks because we're not
00:00
>> actually doing this for real.
00:00
>> The next thing that we needed to do is
00:00
actually set up the networks that were
00:00
being used by the mail host and that's on Line 283.
00:00
We can type in 283 and then capital G,
00:00
and that'll take us to that line.
00:00
Now we can see that it has just
00:00
these bogus network setup.
00:00
What we could do here is just do
00:00
a Shift D to delete the last line and
00:00
hit "Insert" and then we can type in 192.168.1.0,
00:00
which is the network that's actually in
00:00
use here and we're good to go.
00:00
Now I can Escape colon wq.
00:00
Now in order to load these changes,
00:00
we would do a systemctl restart on Postfix,
00:00
and we'll be all set and ready to go.
00:00
Everything has been reloaded and
00:00
this can start surfing mail.
00:00
Now let's take a look at the same thing
00:00
on our Ubuntu system.
00:00
Over here in Ubuntu, it's a little bit different.
00:00
It's a little bit easier in some respects,
00:00
we're going to run a weird command
00:00
here called DEBIAN_PRIORITY=low.
00:00
We're going say that
00:00
we want to do an apt install postfix.
00:00
Here we are in our Ubuntu environment
00:00
and we're going to do this install just
00:00
a little bit differently.
00:00
We're going to go ahead and use a command
00:00
called Debian priority
00:00
to get through a semi interactive install.
00:00
We're going to do that by writing
00:00
DEBIAN_PRIORITY=low apt install postfix.
00:00
What we'll see here is that a bunch of installation
00:00
opens up an interactive text-based installer.
00:00
We need both install and
00:00
configure Postfix at the same time.
00:00
On the first page, we're going to
00:00
select "Internet Site" because
00:00
mail will go through the server using SMTP.
00:00
We don't actually have a domain here,
00:00
but for our purposes we're going to go ahead and
00:00
accept example.com and hit "Okay".
00:00
You usually need to a select user that will get email
00:00
sent when email sent to written postmaster.
00:00
This would probably just be
00:00
a group email or distribution list
00:00
of many systems administrators,
00:00
but for us I'll just use my username
00:00
Rob and then hit "Okay".
00:00
Then we're also going to accept
00:00
all of these other domains.
00:00
If we had other domains, we would add them here,
00:00
so if this is our mail server that was acting as
00:00
an MTA and accept
00:00
the MX records for a bunch of different domains.
00:00
We can specify all of them here,
00:00
but we're just going to hit "Okay".
00:00
Then on this page we're going to select "No"
00:00
because we don't want synchronous updates.
00:00
This is because a bunch of users are
00:00
journal file system so it can
00:00
replay rights from the journal if the system crashes,
00:00
we don't need this.
00:00
Next we need to add the network
00:00
>> that we're going to use.
00:00
>> Again, the network here is 192.168.1.0/24.
00:00
Then we hit "Okay",
00:00
and we can accept all the defaults from here.
00:00
Say "All", and we're good to go, it's done.
00:00
Now if we actually run this systemctl status on this,
00:00
after it finishes, we can
00:00
see that it's installed and running.
00:00
There is systemctl and we're up and running.
00:00
It's just that easy to install Postfix in Ubuntu.
00:00
With that, we've reached the end of this lesson.
00:00
In this lesson we covered
00:00
the importance of mail server services,
00:00
we talked about how mail servers in
00:00
the mail transfer process works at a high level,
00:00
and then we installed Postfix
00:00
>> in both CentOS and Ubuntu.
00:00
>> Thanks so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next
Instructed By
Similar Content