• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 899
  • Last Modified:

What iptables rule can I add to allow outbound SMTP via localhost but cut any remoting..

Hello,
I have a fully functional smtp/pop3/imap server but it turns out at least for now I want to max out my performance and to do so I need to remove the pesky attempts at compromising the smtp/sendmail server.  I know I need to do this because I see excessive messages showing up like: myserver saslauthd[6332]: do_auth         : auth failure: [user=test] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]

Thank g-d I have the saslauthd running - I suspect without requiring such authentication I would have a mass spambot where my server is, however, why not just cut the connection so to speak via the firewall. Now how can I do this and still send mail from localhost processes?
Essentially I wish to shut off access on port 25 to the outside world.
I have no domains with MX records pointing to that domain so no worries there but I do wish to connect to from localhost and send individual messages as required e.g password reset link sending, etc...

So what iptables rules will take my working server and cut off the following annoying logged messages:
Oct 17 19:33:37 myserver saslauthd[6332]: do_auth         : auth failure: [user=test] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]
Oct 17 19:33:40 myserver saslauthd[6337]: do_auth         : auth failure: [user=www] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]
Oct 17 19:33:44 myserver saslauthd[6338]: do_auth         : auth failure: [user=testuser] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]
Oct 17 19:33:48 myserver saslauthd[6334]: do_auth         : auth failure: [user=webadmin] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]
Oct 17 19:33:52 myserver saslauthd[6335]: do_auth         : auth failure: [user=webmaster] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]
Oct 17 19:33:56 myserver saslauthd[6332]: do_auth         : auth failure: [user=accounts] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]
Oct 17 19:33:59 myserver saslauthd[6338]: do_auth         : auth failure: [user=db2admin] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]
Oct 17 19:34:03 myserver saslauthd[6337]: do_auth         : auth failure: [user=ftp] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]

There must be an easy way to keep this outbound send mail only from localhost processes
thereby eliminating any potential hack in threat..
0
Robert Silver
Asked:
Robert Silver
1 Solution
 
Kyle GreenCommented:
If you want to allow only localhost to connect to your SMTP add some iptables rules like
sudo iptables -A INPUT -p tcp -s 127.0.0.0/8 --dport 25 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 25 -j DROP

Open in new window

Don't forget to save!
iptables-save

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now