Forum Discussion

pgopparaju's avatar
pgopparaju
Icon for Nimbostratus rankNimbostratus
Jun 10, 2019

Blocking specific hostnames to send emails through SMTP Realy

Hi,

 

We use F5 BIG-IP as the SMTP relay and need assistance in blocking specific hostnames to send out emails, i did went through some iRules but couldn't find anything that can help me with and also in some articles it's been mentioned that this can be done using filtering if we have AFM module, if so any brief steps on how to do that would be helpful .

 

Thank you.

9 Replies

  • Hi, since there are multiple ways to an F5 as an SMTP relay how are you doing this at the moment? This will give us an idea of what we can suggest

    • pgopparaju's avatar
      pgopparaju
      Icon for Nimbostratus rankNimbostratus

      Hi Kevin,

       

      overview of our setup :

       

      we have a virtual server(SMTP relay host) created on port 25 with a pool of gmail SMTP servers , this virtual server is NATED to an external IP on our edge firewall with SNAT enabled on the F5.

       

      our internal applications are pointed to the relay hostname on the F5 and we want to restrict specific client(applications) hostnames SMTP traffic to be dropped on the F5 before forwarding that to the pool members.

       

      hope i made it clear.

       

      Thanks in advance.

  • Kevin,

     

    Thanks for the links and i do have a question from the below code which you referenced in the link

     

    when CLIENT_ACCEPTED {

    log local0. "client accepted"

    STREAM::expression {=RCPT TO:<[A-Za-z0-9._%+-]+@(?!(myOKDomain|myOtherOKDomain))[A-Za-z0-9.-]+\.[A-Za-z]{2,4}>=RCPT TO:<mail.bucket@mydomain.org>=}

    STREAM::enable

    }

    when STREAM_MATCHED {

    log local0. "Stream filter matched: [STREAM::match]"

    }

     

    so basically do i just need to replace (myOKDomain|myOtherOKDomain) with our from address hosts which i want to block the email from and everything else is passed through the iRule right?

     

    • Kevin_Davies's avatar
      Kevin_Davies
      Icon for MVP rankMVP

      They should be the domains you want to allow.

       

      Inside the expression you will see ?!(myOKDomani|myOtherOKDomain). The ! means not. If you want to match bad domains then remove the !. So it becomes ?(badDomain|anotherbadDomain). Then inside the STREAM::expression add the reject command. This means anything that matches will have its connection killed.