Page 1 of 1

Block certian mail

Posted: Tue Nov 02, 2010 3:52 pm
by Ick
We need to add a rule that would block/drop all outgoing mail except destined for certain mail servers. What is the best way to do this? Still new to MT, but learning lots!

Eric

Re: Block certian mail

Posted: Wed Nov 03, 2010 4:40 pm
by Feklar
/ip firewall filter
add chain=forward action=accept protocol=tcp dst-port=25 dst-address-list=mail_servers in-interface=LAN
add chain=forward action=drop protocol=tcp dst-port=25 in-interface=LAN
Alternatively you can redirect all port 25 traffic to one of your mail servers with a NAT rule instead of just dropping SMTP to mail servers you don't know about.

Re: Block certian mail

Posted: Thu Nov 04, 2010 10:38 am
by normis
destined to certain servers, or sent via certain servers? RouterOS can't filter messages, that you need to do in the mail server that sends them.

Re: Block certian mail

Posted: Thu Nov 04, 2010 7:32 pm
by Ick
Destined to certain servers. We just want to drop everything that isn't meant for our specific mail servers.

Re: Block certian mail

Posted: Fri Nov 05, 2010 7:47 am
by normis
Destined to certain servers. We just want to drop everything that isn't meant for our specific mail servers.
destination of the email message is inside the message. filtering based on that can only be done if you are the SMTP server that sends it. not possible on RouterOS

Re: Block certian mail

Posted: Thu Nov 18, 2010 5:07 pm
by Ick
Destined to certain servers. We just want to drop everything that isn't meant for our specific mail servers.
destination of the email message is inside the message. filtering based on that can only be done if you are the SMTP server that sends it. not possible on RouterOS
We changed out our core router for MT. With our previous router, we had it setup so that it would drop Bots and Worms that were being sent out by infected client computers. So if emails were sent out from client machines that used any email servers other than ours they were dropped.

Some of our professional clients had other company email servers that they used for their business, in this case we would add the ip address of their email server to our list of "approved" Email servers and their email would go through as well.

I still need to get the setup because our upstream provider is whining about it. Any help on this would be appreciated, Thanks

Eric

Re: Block certian mail

Posted: Thu Nov 18, 2010 5:10 pm
by fewi
RouterOS cannot do that.

Re: Block certian mail

Posted: Thu Nov 18, 2010 5:14 pm
by SurferTim
You want to block any new connections from your localnet clients to other email servers than yours for outbound email? This should do:
/ip firewall filter
add chain=forward protocol=tcp port=25 connection-state=new dst-address=!xx.xx.xx.xx action=drop
Replace xx.xx.xx.xx with your email sever ip.

Re: Block certian mail

Posted: Thu Nov 18, 2010 5:19 pm
by Ick
You want to block any new connections from your localnet clients to other email servers than yours for outbound email? This should do:
/ip firewall filter
add chain=forward protocol=tcp port=25 connection-state=new dst-address=!xx.xx.xx.xx action=drop
Replace xx.xx.xx.xx with your email sever ip.
Thanks for the quick reply, how do I add the list of email servers that are ok to send to?

Re: Block certian mail

Posted: Thu Nov 18, 2010 5:21 pm
by fewi
Make an address list enumerating all the servers and use the line Tim gave you with a slight modification to check the address list rather than the destination address directly:
/ip firewall address-list
add list=OK-smtp address=1.1.1.1
add list=OK-smtp address=2.2.2.2
/ip firewall filter
add chain=forward protocol=tcp port=25 connection-state=new dst-address=!OK-smtp action=drop
Completely missed that you weren't trying to block content, just destination.

Re: Block certian mail

Posted: Thu Nov 18, 2010 5:28 pm
by SurferTim
Then use these instead:
/ip firewall filter
add chain=forward protocol=tcp port=25 connection-state=new dst-address-list=email action=accept
add chain=forward protocol=tcp port=25 connection-state=new action=drop
Then put the good server ips (including yours) in
/ip firewall address-list
add address=xx.xx.xx.xx list=email
EDIT: I added "connection-state=new" to each above.

I see fewi already answered. His is the same with one less entry.

Re: Block certian mail

Posted: Mon Nov 22, 2010 6:26 pm
by Ick
Got my list created and all looks good there, however when I type in the last line I get the following:

[admin@www.mikrotikrouter.com] /ip firewall filter> add chain=forward protocol=t
cp port=25 connection-state=new dst-address=!OK-smtp action=drop
value of range must have ip address before '-'
[admin@www.mikrotikrouter.com] /ip firewall filter>
Make an address list enumerating all the servers and use the line Tim gave you with a slight modification to check the address list rather than the destination address directly:
/ip firewall address-list
add list=OK-smtp address=1.1.1.1
add list=OK-smtp address=2.2.2.2
/ip firewall filter
add chain=forward protocol=tcp port=25 connection-state=new dst-address=!OK-smtp action=drop
Completely missed that you weren't trying to block content, just destination.

Re: Block certian mail

Posted: Mon Nov 22, 2010 6:30 pm
by SurferTim
That should have been "dst-address-list=!OK-smtp", not "dst-address". That is why I use my way. I can see easier what is being accepted and what is being dropped. I have not tried "dst-address-list=!address-list".