Koozali.org: home of the SME Server

Need to block internal IPs from sending mail

jpahlow

Need to block internal IPs from sending mail
« on: April 15, 2010, 05:42:02 PM »
I would like to block two particular users (IPs) from sending mail out (all mail - external and internal). 

Would someone please advise me on how-to block (and potentially unblock) a particular IP from using SMTP on SME 7.4?

Thank you for any suggestions


Offline mmccarn

  • *
  • 2,656
  • +10/-0
Re: Need to block internal IPs from sending mail
« Reply #1 on: April 16, 2010, 02:29:37 PM »
There's nothing I'm aware of at the moment to do what you want to do; you're also going to have to be pretty sneaky about it.

If you just want to block access to port 25 (for example) from a LAN workstation to your SME, and if you're adventurous, you may be able to make it work like the 'Block outgoing ports' and 'Bypass Proxy' methods described at http://wiki.contribs.org/Firewall#Open_Ports_in_Private_Server.2FGateway_Mode

As far as I can tell, you need to insert rules into the 'nat' table of iptables, in the 'local_chk' chain (or better, the 'local_chk_###' chain), something like this:
Code: [Select]
# deny traffic from 192.168.x.y to port 25 on any host
/sbin/iptables --table nat --insert local_chk --source 192.168.x.y --destination 0.0.0.0/0 --dpt 25 --jump denylog

However, this won't prevent the miscreant workstations from connecting to an off-site smtp server on an alternate smtp port (465, 587, 2525, other), or using webmail (80, 443, other) - so you may want to use the "Block outgoing ports" instructions to block all outbound traffic from these users.

If you're dealing with actual people, who have access to google, who are smart enough to get through junior highschool, and who want to send email even though you don't want them to, you'll need to:
- block all internet traffic (proxied or otherwise) for those users
- make sure they don't have iphones, blackberries, or any other way to access your server from "outside"


If you're working with possibly infected computers that may go nuts and send spam all over the place, you should be able to protect yourself by:
- Use Block outgoing ports to block traffic to all ports from the offending workstations
- Disable the 'SMTP proxy' on your SME server
- Enable SMTP authentication for users on the internal network
- Disable SMTP relay for unauthenticated LAN clients