Making Sendmail listen on the loopback interface only under Slackware

Posted on . Updated on .

Slackware is one of the few "important" distributions which ships Sendmail by default instead of another MTA like Postfix, qmail or Exim. In any case, the important detail is that it’s usually a good idea to run an MTA in your computer. Many programs like cron use the sendmail command to mail the output of the programs they run. This output is generally empty but when it’s not, cron mails it because it will probably contain error messages. Another good idea is to have the root email account aliased to your normal user, so you don’t forget to check these error messages and detect problems as soon as possible. Further setup may involve setting up your email client (be it KMail, Thunderbird or whatever) to check this local mail account.

In any case, let’s suppose you don’t mind which MTA Slackware installs as long as you have your ass covered, so you have Sendmail installed but, by running netstat --listen --tcp --udp or a similar command you discover Sendmail is listening to the world in not one but probably two different ports. You may want to disable the second port, which may be important if your machine was a real mail server, but it’s not. You may also want to make Sendmail listen on the loopback interface only. It’s quite simple.

You need to install the m4 and sendmail-cf packages if they’re not already installed, apart from the obvious sendmail package which will probably be already present in your system. Head to the /usr/share/sendmail/cf/cf/ directory. You will find a file called there, which stores the default configuration values. I’d recommend making a copy of the file instead of modifying it directly, with a meaningful name like or

Open the copy and add the following line in the "FEATURE" block:


Also, before the "MAILER" lines, add the following line:


Processing that file with the m4 command from that directory will output a configuration file suitable to replace the default present in /etc/mail/. Hence, run the following command replacing with the name you chose:

m4 >/etc/mail/

And finally restart Sendmail by running :

/etc/rc.d/rc.sendmail restart

If you now run netstat again, you should see Sendmail listening only on port number 25, on the loopback interface and unreachable from the outside world. I’m not really sure if you need to add the lines in those specific positions. Probably, a Sendmail expert will know if you can or cannot, but I haven’t tried. It works without errors in the positions I mentioned above.

comments powered by Disqus