WEB375 Lab 3: Configure a sendmail server in Linux
The purpose of this lab is to configure a sendmail server in Linux. Use the IP addresses that exist when you start Linux.
Virtual Machine Login Information for PLABFED01 and PLABFED02
During your session, you will have access to the following lab configuration.
WINCONSOLE PLABFED01 PLABFED02
The Linux servers also connect to a private network. The IP address of PLABFED01 is 192.168.240.11 and the IP address of PLABFED01 is 192.168.240.12.
Connecting to Your Lab
In this module, you will be working on the following equipment to carry out the steps defined in each exercise.
• WINCONSOLE (Management Server)
• PLABFED01 (Linux Server)
• PLABFED02 (Linux Server)
Each exercise will detail which console you are required to work on to carry out the steps.
To start, simply click on the named server from the device list (located on the left-hand side of the screen) and click the “Power on” button from the Tools bar. In some cases, the devices may power on automatically.
During the boot-up process, an activity indicator will be displayed in the Name tab.
• Black—Powered off
• Orange—Working on your request
• Green—Ready to access
If the remote console is not displayed automatically in the main window (or pop-up), click the Connect icon located in the Tools bar to start your session.
If the remote console does not appear, please try the following option.
• Switch between the HTML 5 and Java client versions in the Tools bar.
In the event this does not resolve your connectivity problems, please visit our Help and Support pages for additional resolution options.
sendmail Configuration Step by Step
We configure the sendmail server for our local LAN in this lab.
The sendmail daemon is configured from a directory of files in /etc/mail and a directory of configuration files in /usr/share/sendmail-cf. There are two basic configuration files.
• /etc/mail/sendmail.cf The main sendmail configuration file
• /etc/mail/sendmail.mc A macro that’s easier to edit, which can be used to generate a new sendmail.cf file
The configuration file that the sendmail server program reads is /etc/mail/sendmail.cf. But to change the configuration on the mail server, we modify the /etc/mail/sendmail.mc file using a text editor such as nano or vi. There are two ways to generate the sendmail.cf file: Start or restart the sendmail program or use the m4 command.
For this lab, we are using one Linux server, plabfed01, with IP address 192.168.240.11.
TASK A—Configure sendmail Server
Step 1. Use TigerVNC to log in to the plabfed01 system, open a terminal window, and switch to root (or you can use Putty to log in plabfed01 as root). Make sure the sendmail, mailx, and m4 packages are installed. Type the following commands.
#rpm –qa sendmail *
#rpm –qa mailx
#rpm –qa m4*
If they are installed, the commands’ outputs look like this.
Step 2. If it tells you that the packages are not installed, then you need to install them; otherwise, skip Step 2.
To install sendmail on the Fedora Linux system, type the following.
#yum –y install sendmail
In order to configure sendmail, make sure to install the sendmail -cf package. To install sendmail.cf, type the following.
#yum –y install sendmail -cf
Sometime you may use the m4 macro processor to create a new /etc/mail/sendmail.cf. To install m4, type the following.
#yum –y install m4
To install a text-based utility program for sending and receiving mail, type the following.
#yum –y install mailx
To install all of the above packages, type the following.
#yum –y install sendmail sendmail -cf mailx m4
Step 3. You need to add your domain in /etc/hosts file to have sendmail configured correctly. Use nano or vi to edit the /etc/hosts file; its content should look like this.
Step 4. To make the hostname permanent, modify /etc/sysconfig/network file using nano or vi as editor. The file’s content should look like this.
Step 5. To modify the hostname for the current session using the command hostname, type the following.
Step 6. Use nano or vi to add your domain entry in /etc/mail/local-host-names file, which is a list of hostnames sendmail is to accept as the local host name. Your file should look like this.
Step 7. To allow sendmail to accept network connections from any host, use nano or vi to modify the /etc/mail/sendmail.mc file and add the “dnl #” in front of line number 118. The string “dnl” is used for commenting.
Note: DNL stands for “delete to new line.”
Step 8. To generate a new sendmail.cf file by using m4, type the following.
#m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Step 9. Now that we are ready to start sendmail, type the following.
#systemctl start sendmail.service
Step 10. To check sendmail status, type the following.
#systemctl status sendmail.service
An active sendmail status looks like this.
Note: If sendmail fails starting, check for errors using the command journalctl –xn, fix any typos, and restart the service with command #systemctl restart Sendmail.service until sendmail starts successfully. Below is a sample of journalctl –xn command output without any error.
Step 11. To enable the sendmail server at boot time, type the following.
#systemctl enable sendmail.service
TASK B—Validation and Testing
Step 1. Check the sendmail to listen to all interfaces at the host using this command.
#netstat –an | grep :25 | grep tcp
Below is a sample output of the netstat command.
Step 2. Create two test users for testing purposes (that will send and receive mail), use the following commands to add user accounts and to change user’s password. Use the password Password for the testuser accounts. For the next several steps, my examples use user1 and user2 accounts. In the lab, you use testuser1 and testuser2 accounts.
Below are examples; I used user1 and user2 accounts (yours are a little bit different).
Step 3. Log in as the testuser1 and try to send mail using the mail command (tou can switch from root to testuser1).
Here are some examples.
• You can switch from root to testuser1 using su—testuser1. To exit from testuser1, type exit to get back to root.
• When using mailx, to terminate the text message, type . (dot), then hit the Enter key.
Step 4. To see whether the mail was sent correctly, use journalctl –xn to display messages.
Step 5. To check whether mail is delivered to testuser2, log in as the testuser2 and try to read mail using the mail command (again, you can switch from root to testuser2).
For example, see below.
• If there is more than one message, type the message number and hit the Enter key to read.
• To exit mailx, type q, then hit Enter.
TASK C—Lab Report Preparation
Step 1. Be sure you’re in the root account. Clear the screen, type the command #cat /etc/hosts to display its contents, and capture the Linux desktop, then save this image to your Lab Report document in the space allocated for the /etc/hosts file.
Step 2. Be sure you’re in the root account. Clear the screen and type the command #systemctl status sendmail.service to display the sendmail daemon status and capture the Linux desktop, then save this image to your Lab Report document in the space allocated for the #systemctl status sendmail.service command.
Step 3. Be sure you’re in the root account. Clear the screen and use the command #tail -4 /etc/passwd file to display its last four lines and capture the Linux desktop, then save this image to your Lab Report document in the space allocated for the #tail -4 /etc/passwd command.
Step 4. Switch to testuser1. Use the mail command to send the message “Hello!!! My name is ‘your first name’” (include your real first name) to testuser2. Capture the Linux desktop and save this image to your Lab Report document in the space allocated for sending mail to testuser2.
Step 5. Switch to testuser2. Use the mail command to read the message from testuser1. Capture the Linux desktop and save this image to your Lab Report document in the space allocated for read mail from testuser1.
This concludes Lab 3.
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at [email protected].
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.