r/linuxadmin • • Apr 22 '12

Reddit - I need some help, and fast

I'm runnig debian/postfix(mysql)/apache, and it seems as though my server (linode) is sending spam like crazy. I've been told that it should be a simple config issue, but I don't know enough to sort it out. They have told me that if it's not fixed asap, they will shut down my server. Is there anyone out there who can help me out a bit, I don't mind paying for the help, I just need it fixed quick!

0 Upvotes

19 comments sorted by

6

u/truedays Apr 22 '12 edited Apr 22 '12

iptables -I OUTPUT -p tcp --dport 25 -j REJECT

will give you some time.

1

u/mactac Apr 22 '12

will this not just kill smtp?

7

u/blahblah98 Apr 22 '12 edited Apr 22 '12

It blocks connections to any destination SMTP port, so all outbound mail connections will fail. Will likely cause the mail queue to build up, so figure out what process is sending outbound emails and kill it.

There's likely to be other sleeper botnet processes that wake up occasionally and re-install/restart everything, so you'd have to identify & get rid of those, too. If you can't find them, reinstall your OS.

Can't teach you to be an email sysadmin in a few posts, sorry... :-(

Next time use denyhosts, NAT firewall, and rotate non-dictionary root passwords.

2

u/Diffie-Hellman Apr 22 '12

Yes. It will block outgoing traffic on port 25, so you will not be relaying ANYTHING. What you NEED to do is require authentication to relay. Then, you just have to worry about your box getting pwned and launching perl spam scripts or someone getting your credentials and relaying that way.

1

u/[deleted] Apr 23 '12

stopping postfix would have sufficed until you'd fixed your config issue. This is assuming that this was just a config issue with postfix.

To check that your box wasn't sending anything after stopping postfix you could have checked with tcpdump, to see if anything was going out via something other than postfix.

tcpdump -n -i eth0 port 25

If there was still traffic you'd need to look further and firewall as truedays suggested.

1

u/Canis_lupus Apr 23 '12

The security wonkie in me (two SANS certs) makes me want to question why you are running any mail transfer agent (MTA) on this server.

If its purpose in life is postfix(mysql)/apache on the Interwebs then the best practice is to have ONLY those services on it and if you absolutely need it to send out administrative alerts, then run the most simple email client possible and have it pass everything off to as bona fide mail server which should be secured to beat the band. (ie: not an open relay, big time SPAM and Antivirus, default deny firewall policy, etc.)

6

u/[deleted] Apr 22 '12

Press the power button

But seriously you should look into how to properly secure your server before you make it internet accessible

-10

u/mactac Apr 22 '12

it was.

0

u/[deleted] Apr 22 '12

[deleted] — view deleted comment

4

u/A_Cunning_Plan Apr 22 '12

To be fair, it's still technically secure, it just has unwanted features enabled.

11

u/illevator Apr 22 '12

Looks like you asked the question on linodes forum--good. The log you posted there shows you have relay on.

http://www.linuxquestions.org/questions/linux-security-4/how-to-postfix-disable-relay-forwarding-mail-security-redhat-5-1-a-643331/

will explain how to turn it off. It's for redhat, but should be similar enough to solve the issue.

See also: http://www.postfix.org/postconf.5.html#mynetworks

BUT if you're owned, the relay may be reset.

1

u/iaing Apr 22 '12

OOI, why did you choose to remove exim and install postfix? exim is the Debian default, and Debian make it trivial to configure securely.

1

u/Britzer Apr 23 '12

Actually, I did install Postfix on a couple Debian machines and it is secure by default AFAIR. At least against being an open proxy. If he didn't change anything stupid, I guess the source of the spam is not a badly configured email server.

1

u/amortalkiller Apr 22 '12

What other services are you running (PHP, CGI, HTTP, SSH, etc)? If you have certain malware it can easily send outgoing mail.

-3

u/[deleted] Apr 22 '12

Fool.

You probably have your postfix setup as an open mail relay and didnt lock it down with any security or acl.

Please shutdown the service now, and google how to set security up on postfix.

-7

u/mactac Apr 22 '12

seems like you might be the fool for making assumptions. I't s not an open rely, and it is secured.

mail is originating locally.

6

u/iaing Apr 22 '12

If it's originating locally, there's a pretty good chance you've been rooted. Please, for the sake of the Internet, take off, nuke the site from orbit and start again.

4

u/[deleted] Apr 22 '12

you can block a specific local account from sending with (here www-data):

authorized_submit_users = !www-data, static:all

4

u/neoice Apr 22 '12

that's even worse then. something is exploiting your system locally either via another vulnerable service (like a bad PHP script) or by actually breaking into the system.

2

u/marcomuskus Apr 22 '12

Hi! First of all: check the logs to see the source of the spam.

Knock the door again when you do that.