3

I have a server "CentOS 5" I would like to block all outgoing mail temporarily. Server is using sendmail. Preferably using iptables if applicable. I still need email to come into the machine tho if that can be accomplished at the same time.

Thank you

3 Answers 3

5

Sure, this is possible. You should be able to just add an iptables rule which blocks outgoing connections on the sendmail port. Use a command something like,

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

and iptables will reject all outgoing connections on port 25.

3
  • ajdecon, thanks just what I'm looking for. It gives me the following error however. I might also add the I was thinking of another server when I said CentOS 5. This server is running RH 4 and iptables 1.2.11 -bash-3.00# iptables -A OUTPUT --dport 25 -j REJECT iptables v1.2.11: Unknown arg --dport' Try iptables -h' or 'iptables --help' for more information.
    – bckr
    Apr 11, 2011 at 13:24
  • Oops, I spaced. iptables wants to know which transport protocol you're using; the command should be, iptables -A OUTPUT -p tcp --dport 25 -j REJECT so that it knows to use TCP.
    – ajdecon
    Apr 11, 2011 at 13:35
  • ajdecon, Thanks, that did the trick. Thanks so much for the help. I have learned a bit as well. Thank you!
    – bckr
    Apr 11, 2011 at 14:11
0

You could just block TCP port 25 in your outgoing firewall, probably simpler to implement than changing your mail settings plus all the outgoing mail should just 'build-up' ready for retransmission attempts later once you've 'released the valve'.

1
  • Chopper, When you say firewall are you talking about iptables or the hosts hardware/software firewall? If I can just block/stop outbound mail while allowing email to still come in with iptables I would prefer this method.
    – bckr
    Apr 11, 2011 at 13:13
0

If your server is running as a sendmail relay, look at setting up relay-domains. You could add all your domains to /etc/mail/relay-domains restart sendmail.

This will let sendmail check before sending out. If you then remove entries from this file the none allowed domain mails will queue until you re-add them. Upon restart sendmail will process the queue and all should be happy.

1
  • Andy, thanks for this additional information. Very helpful.
    – bckr
    Apr 13, 2011 at 4:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .