Sendmail Setup for Your Home Network
Sendmail is an extraordinary piece of software, adaptable for complex to modest installations with different needs. Almost every UNIX administrator has faced the installation and configuration procedures of Sendmail and learned that the available options are extensive and, sometimes, frustrating.
In this article we will address a basic installation procedure (sort of a recipe for a quick set up of your mail server) for the average user. Assuming the system is a home or small company network with a Linux machine running Sendmail as the mail server, Sendmail's functions will be to receive mail messages from machines on the internal network, deliver local messages to their respective users and deliver to the Internet messages for external destinations. Additionally, the server will receive mail from the Internet.
I assume an internal network domain with the name intranet.mydomain.com, and the machines in this network use non-public IP numbers of the form 192.168.XXX.XXX. The mail server has an interface connected to the Internet with a real IP number needed for external mail reception using the domain mydomain.com.
In my experience I have found having different domains for internal and external networks makes it easier to have other types of setups, like DNS (domain name services), separate traffic and privacy.
Every Linux distribution includes Sendmail as one of the basic programs and some default configuration files that work well. However, if you are concerned about security or you are a do-it-yourself person, it is advisable to install the latest version of Sendmail. The procedure is straightforward, and you can use an updated RPM or download the source code from www.sendmail.org (I prefer the last method). Next, extract the sources and compile the program using the predefined scripts.
The following is a listing of the commands I used to unzip the tar file and build the code on my machine, which runs a Red Hat Linux 6.2 distribution.
$ tar -zxvf sendmail.8.11.2.tar.gz $ cd sendmail-8.11.2 $ ./Build $ su # ./Build install
Now you must set up the configuration files. If you have compiled the source version without modifications, all the required files will live in /etc/mail/. The most important file is /etc/mail/sendmail.cf; this file holds the options necessary for Sendmail to work and is a text file. In the old days, you would have had to edit this by hand to change the configuration, and if you look at the text, it is somewhat confusing.
Fortunately newer versions of Sendmail come with an easier setup procedure based on predefined blocks and macros that hide the details of the configuration--think of it as compiling a configuration file for Sendmail.
The following commands can be used to generate a valid Sendmail configuration file from the cf/cf subdirectory of the source directory.
$ cd sendmail-8.11.2 $ cd cf/cf $ cp generic-linux.mc myconfig.mc $ m4 ../m4/cf.m4 myconfig.mc > sendmail.cf
The resulting sendmail.cf file can be installed in /etc/mail and used to run the Sendmail server. You must restart the service to activate the new options. For Red Hat, this can be done with a command like:
# /etc/rc.d/init/sendmail restart
Now that you have generated a standard setup file for Sendmail, the next step is to build a file for the main mail server, the one that manages e-mail both internal and external on your network.
Listing 1 shows the complete source file for the configuration. I will now cover each of the features in more detail.
The combination of the allmasquerade, masquerade_envelope and MASQUERADE_AS features and directives are used to hide the names of the hosts in your internal network and make the mail messages appear to come from mydomain.com. This way you have a more uniform address across your organization, regardless of the internal machine used to send the e-mail.
The other section added to this file rewrites the recipient's address. This kind of rewrite generally occurs when an internal machine or a local program is used to send e-mail (pine on the mail server, for example). In that case the recipient address may contain the server name and intranet domain. What this rewrites does is catch this type of recipient address and rewrite it to a uniform address.
Creating a Configuration File for a Linux Client Machine
For the internal Linux machines on our network, we can create a configuration file because the client machines use the mail server (mailhub) to send the e-mail. In this form, all of the rewrites and masquerading rules already discussed before are applied to the mail sent from these machines. The contents of the file are:
OSTYPE(linux)dnl DOMAIN(generic)dnl MAILER(local)dnl MAILER(smtp)dnl FEATURE(nullclient, mailhub)dnl
The magic comes from the last line of this file. FEATURE(nullcient, mailhub) indicates we are using "mailhub" as our mail server. The Sendmail process on the client machines simply sent the e-mail to this server.
The procedure for generating the final sendmail.cf file is the same as specified in the previous section.
Practical Task Scheduling Deployment
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.View Now!
|The Firebird Project's Firebird Relational Database||Jul 29, 2016|
|Stunnel Security for Oracle||Jul 28, 2016|
|SUSE LLC's SUSE Manager||Jul 21, 2016|
|My +1 Sword of Productivity||Jul 20, 2016|
|Non-Linux FOSS: Caffeine!||Jul 19, 2016|
|Murat Yener and Onur Dundar's Expert Android Studio (Wrox)||Jul 18, 2016|
- The Firebird Project's Firebird Relational Database
- Stunnel Security for Oracle
- My +1 Sword of Productivity
- SUSE LLC's SUSE Manager
- Non-Linux FOSS: Caffeine!
- Managing Linux Using Puppet
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Parsing an RSS News Feed with a Bash Script
- Google's SwiftShader Released
- Doing for User Space What We Did for Kernel Space
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide