This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Restrict Inbound IP's connecting to SMTP Proxy

I've done a little search, and cannot find anything answering this:

Is it possible to restrict the source IP's that can connect to the SMTP proxy?
Obviously if I don't use the proxy, I can restrict the IPs that are allowed to connect to my internal mail server, but I'd like to play with some of the new features in ASL4 now I finally got round to upgrading from 3.2 on my home network.
The reason for wanting to restrict the IPs is that I use MessageLabs SkyScan services (as I work for them!) and all my mail comes through their systems, so I need to restrict my inbound mail to only come from their IPs.

Thanks in advance,

Karl 


This thread was automatically locked due to age.
Parents
  • Why not just create a rule and allow only your desired IP range to access the inbound SMTP server? Other servers won't be able to access any way if there is not a specific rule to allow them.

    Maurice 
  • Yep, that's what I do at the moment, as I currently do not use the smtp proxy, but I would like to use the ASL smtp proxy, but only if it is possible to restrict which IP's on the internet can relay inbound to me. 
  • kd,

    I'm not sure I am understanding what you are trying to accomplish.  Do you only want certain SMTP servers to be able to send mail to your server, or do you just want to make sure that your SMTP proxy does not become an open relay?

    I'm only asking because when you set up the SMTP proxy, you define the domain and where you want it sent to.  So if you have domain abc.com you can configure the proxy so that only e-mail traffic for users at abc.com will be forwarded to your inbound SMTP server.  Anyone can send e-mail to a user at abc.com, but they cannot relay off your SMTP proxy for any other domain.

    If you are referring to creating a packet filter rule so that Host X, Host Y, and Host Z can access "External_Interface" on service SMTP, then I don't know the answer off the top of my head.

    You do not have to create any rules to allow SMTP access to your firewall when SMTP Proxy is turned on.  The question is, does the firewall decide to accept this traffic before or after it looks at the user defined packet filters (but obviously before the implicit deny all at the end).  If it accepts the traffic before checking the packet filter, I'm not sure if anything can be done.  If the check is done after looking at the user defined packet filter rules, then you should be able to solve that with 2 rules.  The first rule permits the appropriate traffic, and the second rule denies all other SMTP traffic to the external_interface.

    I'm curious how this works myself, so I'll probably try to test this and post my results unless someone else posts the answer first.
      
  • Hmmm.... Sorry, re-reading my posts, I wasn't completly clear (sorry!). I'm trying to restrict the IP addresses on the internet that can *connect* to my SMTP Proxy to send mail inbound to me. As mentioned before, I use MessageLabs services for my inbound virus scanning, anti-spam etc, and so need to restrict inbound connections to my SMTP proxy to only allow their servers to connect to me. 
  • just to confirm : I enabled the SMTP proxy, and created a rule :

    Any Any external_Interface__ Reject

    moved it to be rule 1 and enabled it, and was still able to connect to port 25 from outside.

    This was the case with ASL3.2, but after your question, I thought I'd confirm the same to be true with ASL4.

    I've also had a look through the Exim documentation, and for exim 3 there was a host_reject option, but I can't find the equivalent with Exim 4.

    Cheers,

    Karl 
  • Hmmm...  If the packet filter rules don't affect the SMTP Proxy, then I am not aware of a way to limit traffic from specific hosts.  Maybe someone else on the forums have figured this out already.

    Sorry [:(]  
  • No problem. Thanks for your suggestions.

    I think it may be possible to restrict incoming in exim.conf somewhere, but I'm more familiar with qmail. I need to read the [exim] docs more, as my tinkering has not worked so far.

    Thanks again,

    Karl 
  • When you enable smtp-proxy there will be automatically created a rule (for ip-tables). This rule will allow all traffic to connect to your ASL - on either interface - but does not mean that they can relay. This is beeing limited by [Allowed Networks:]
    Since this rule is placed in a chain BEFORE your custom policy it will always match before yours will drop.
    So what can you do about that: either "hack" ip-tables or do NOT use smtp-relay but setup a rule that will allow smtp from your provider through the ASL right to your internal mail server.

    techno.kid   
  • Ah. There's an idea. To be honest, I'd not thought of that. The best answer is usually the simplest.

    I'll have a look for the iptables configs, and see if I can hack it, so that if smtp proxy is enabled, the rule that gets created is the restricted one I want [:$])

    >>but setup a rule that will allow smtp from your provider through the ASL right to your internal mail server

    This is what I currently do, but I'd like to play around with the new features in the proxy.

    Thanks,

    Karl 
  • Just for my own curiosity, if you hack the IP Tables configuration, are there any changes you can make in WebAdmin that will revert your manual changes, or even break the IP Tables config?

    I'm thinking of a situation where you hack the IP tables config to limit the inbound servers that can access the proxy.  If you disable and re-enable the proxy, how will it respond?  Will it fail to disable the hacked IP Tables rule because it isn't the same as the original rule that was defined by WebAdmin?    Or perhaps there are options in the WebAdmin that may cause the entire IP Tables config to be re-generated, which will overwrite your hacked changes.

    I'm just wondering what the chances are of accidentally destroying your firewall config when you start hacking files that the WebAdmin will modify.  
  • I can't look until later today, but, I'm hoping that there will be a defaults config file where I can change the line that get's added and removed. If I hack it, I want it to work seamlessly, without needing attention after a reboot etc.
    I'll give a scan with nessus after from out on the net as well..... 
  • Hmmm. Can't find it. Can someone at Astaro let me know if this rule is in a template somewhere, or if it is hard coded somewhere in the depths of the (what looks like) compiled perl [:)]
    The rule I'm looking for is the default mail rule that gets added to AUTO_INPUT :

    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0          tcp spts:1:65535 dpt:25

    That gets changed automatically to :

    ACCEPT       tcp  --  0.0.0.0/0            0.0.0.0/0          tcp spts:1:65535 dpt:25

    When the smtp proxy is enabled. I'd like to change it to only allow a restricted network range to connect to me -- my MX records point to a MessageLabs server, and they relay to me -- so I just want to accept from them.....

    If it's hard coded, then I'm out of luck!

    Thanks in advance,

    Karl 
Reply
  • Hmmm. Can't find it. Can someone at Astaro let me know if this rule is in a template somewhere, or if it is hard coded somewhere in the depths of the (what looks like) compiled perl [:)]
    The rule I'm looking for is the default mail rule that gets added to AUTO_INPUT :

    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0          tcp spts:1:65535 dpt:25

    That gets changed automatically to :

    ACCEPT       tcp  --  0.0.0.0/0            0.0.0.0/0          tcp spts:1:65535 dpt:25

    When the smtp proxy is enabled. I'd like to change it to only allow a restricted network range to connect to me -- my MX records point to a MessageLabs server, and they relay to me -- so I just want to accept from them.....

    If it's hard coded, then I'm out of luck!

    Thanks in advance,

    Karl 
Children