Setting Up an SMTP Relay Server for Your Homelab

If you have a homelab consisting of various services running on an assortment of random hardware, it often proves essential to have a simple SMTP relay for sending out emails. The relay server can consolidate email traffic and push them through a single authenticated email account provided by your hosting provider.

In this article, we will walk you through setting up an SMTP relay server using Ubuntu and Postfix. This setup will allow you to gather email from your local network and deliver them via an SMTP-enabled account from your hosting provider.

Prerequisites

  • A fresh Ubuntu server or vm. This guide is using an Ubuntu 22.04 vm running in a VMware environment.
    • Fully patched
    • Static IP or DHCP Reservation (best-practice for most services).
  • An account with your hosting provider, with SMTP-enabled service.
  • Basic knowledge of Linux command-line operations.

Step 1: Install Postfix

First, we’ll need to install Postfix, a free and open-source mail transfer agent that routes and delivers electronic mail. To do this, run the following commands:
sudo apt-get update
sudo apt-get install postfix mailutils

During the installation process, a configuration window will appear:

  1. Choose “Internet Site” for the type of mail configuration.
  2. For the system mail name, enter the domain name of the email address you’re using, usually everything to the right of the ‘@’ symbol.

Step 2: Configure Postfix

Open the main Postfix configuration file with your preferred text editor. We will use nano in this guide:

sudo nano /etc/postfix/main.cf

Find and modify the following lines in the file to match the information below. If a line isn’t found, add it and make it match the information below.:

inet_interfaces = all
mydestination = localhost
relayhost = [smtp.yourprovider.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

smtp_use_tls = yes

mynetworks = [safe networks]

Replace “safe networks” with a comma-separated list of subnets in CIDR format. Clients sending mail from these subnets will be allowed to do so without authentication. Set this carefully!

Replace “smtp.yourprovider.com” with the SMTP server of your hosting provider.

Once complete, write out your changes and exit nano.

Step 3: Set Up Authentication

Now, we need to set up the SMTP username and password that Postfix will use to send emails.

First, create a new file:

sudo nano /etc/postfix/sasl_passwd

Next, add the following line, replacing the SMTP server, username, and password with your information:

[smtp.yourprovider.com]:587 yourusername:yourpassword

Once complete, write out your changes and exit nano.

Now, create a hash db file for Postfix by running the following command:

sudo postmap /etc/postfix/sasl_passwd

Then, for security reasons, delete the unencrypted sasl_passwd file:

sudo rm /etc/postfix/sasl_passwd

Step 4: Update File Permissions

You need to set the appropriate permissions for the sasl_passwd.db file to ensure the Postfix user can read it:

sudo chown root:root /etc/postfix/sasl_passwd.db
sudo chmod 0600 /etc/postfix/sasl_passwd.db

Step 5: Create a Mapping File

This map tells Postfix that all email relayed through this server should be sent as if it originated from the account from our hosting provider.:

sudo nano /etc/postfix/sender_canonical

Then, add your mapping rule.:

@local.domain.example.local yourusername@yourprovider.com

Once complete, write out your changes and exit nano.

Step 6: Create a Postfix Lookup Table

Now you need to create the Postfix lookup table from the file created in the last step:

sudo postmap /etc/postfix/sender_canonical

This command will create a file called ‘sender_canonical.db’ that Postfix will use. Now we need to edit the Postfix configuration again.:

sudo nano /etc/postfix/main.cf

Add the following line:

sender_canonical_maps = hash:/etc/postfix/sender_canonical

Once complete, write out your changes and exit nano.

Step 7: Restart Postfix

Finally, apply all the changes by restarting or reloading Postfix:

sudo systemctl restart postfix

Step 8: Test Your Setup

To make sure your SMTP relay works properly, you can send a test email to any of your active email accounts. To do this, use the ‘mail’ command:

echo "Test mail body" | mail -s "Test mail subject" your-email@example.com

If everything works correctly, you should receive this test email.

Homelabs for Development

The Power of a Homelab

What’s the allure of a homelab? It’s more than just a hobby. A homelab serves as a personal playground, an innovative environment where you can freely experiment, make mistakes, learn, and innovate. It provides a unique platform to test new technologies, validate concepts, and keep your skills sharp in the fast-paced world of IT.

For businesses, having engineers with homelabs offers immense value. Here’s why:

1. Cutting-Edge Skills: Homelabs provide a unique opportunity to experiment with the latest technology, stay ahead of the curve, and develop cutting-edge skills, making engineers more competitive and valuable to their organizations.

2. Improved Problem-Solving: By managing a personal datacenter, engineers sharpen their problem-solving skills. They face and overcome real-world challenges on a smaller scale, which translates to better troubleshooting abilities in a corporate setting.

3. Innovation and Creativity: Homelabs are a haven for innovation and creativity. Here, engineers are free to experiment without constraints or repercussions, fostering a mindset that can lead to groundbreaking ideas and solutions in the workplace.

4. Risk Management: Homelabs offer a safe space for testing and validation, which can mitigate business risks. Before implementing new solutions or architectures in the business environment, they can be tested extensively in a homelab.

5. Cost-Effective Learning: Engineers learn most effectively by doing. With homelabs, they can hone their skills and knowledge at their own pace and in their own space, saving businesses the cost of formal training and certification.

In a nutshell, a homelab is a valuable tool that fuels continuous learning, fosters innovative thinking, and facilitates the development of practical skills that can drive professional growth and business success.

Upgrading vCenter from 7.0.3 to 8.0.1: A Guided Walkthrough

Hello beautiful people! Today, we’re embarking on a crucial journey – upgrading our vCenter from version 7.0.3 to the latest 8.0.1. The updated version brings a host of enhancements, improved security, and new features, ensuring that our virtualized environments remain at the cutting edge of technology.

In this blog post, I’ll guide you through the upgrade process using the Windows UI Installer. But remember, every environment is unique, so make sure to tailor these steps to fit your own needs and to refer to VMware’s official documentation for any clarifying points.

Before You Start

Ensure you have a backup of your vCenter Server. An upgrade process usually goes smoothly, but it’s better to be safe than sorry.

Step 1: Download the Installer

The first step is to download the latest vCenter Server Appliance (vCSA) ISO file from the VMware website. This ISO file includes the Windows UI Installer we’re going to use for the upgrade process.

Step 2: Mount the ISO

Once downloaded, mount the ISO file on your Windows machine. Navigate to the “vcsa-ui-installer\win32” directory and run the installer.exe file.

Step 3: Upgrade vCenter Server

In the installer window, you’ll see several options. Choose the “Upgrade” option.

The upgrade process is broken down into two stages:

Stage 1: Deploy vCenter Server Appliance

This stage involves deploying a new vCSA with a temporary network identity.

  1. Click on “Next” and accept the End User License Agreement.
  2. Enter the details of your existing vCenter Server and the ESXi host or vCenter Server that manages it.
  3. Specify the VM name and root password for the new vCenter Server.
  4. Choose a deployment size and storage size based on your environment’s needs.
  5. Configure the temporary network settings for the new vCenter Server.

Review your settings and click on “Finish” to deploy the new vCenter Server. This can take some time, so be patient.

Stage 2: Copy Data

This stage involves migrating data from the old vCenter Server to the new one.

  1. Once Stage 1 completes, continue to Stage 2. The installer will run a pre-upgrade check. Review the results and resolve any issues.
  2. Select the data you wish to copy from the old vCenter Server. You can choose between configuration, configuration plus events and tasks, or everything, including historical performance data.
  3. Confirm the new vCenter Server’s network settings.

Review your settings and click on “Finish” to start the data copying process. This process can take quite a bit of time depending on the amount of data you’re transferring.

After the upgrade process is complete, you can log in to your shiny new vCenter Server using your previous credentials. Remember to validate all settings and functionality after the upgrade process.

Conclusion

And there you have it! Your vCenter has been successfully upgraded from 7.0.3 to 8.0.1. Keep in mind this is a simplified guide. For more details, always refer to the official VMware vCenter documentation. Enjoy exploring the new features and enhancements that come with vCenter 8.0.1!

Remember, the key to a successful upgrade process is preparation and understanding your unique environment. Happy upgrading!