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..
LVL 2
Robert SilverSr. Software EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Security

From novice to tech pro — start learning today.