CodeShare
Have some code. Share some code.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner
Jeff_Silverman2
Historic F5 Account

Problem this snippet solves:

I had a customer who wanted to use a single virtual IP address for a mail server, but have the mail go to different pools depending on whether the mail was internal or external. So I wrote the following iRule which I connected to the SMTP virtual server definition. This script assumes that the LTM floating IP address is set as the default gateway for the physical servers, because the physical servers are going to see source IP addresses from all over the world. If, for some reason, the physical servers have to have their default gateways set to someplace else, then add a snat automap command after the when CLIENT_ACCEPTED command.

Code :

rule smtp_direct_rule {
   when CLIENT_ACCEPTED {
     if { [IP::addr [IP::remote_addr] equals 10.2.0.0/255.255.0.0 ] }  {
         log local0. "Node IP address is: [IP::remote_addr] and sent to SMTP_clients_from_10.2"
         pool smtp_clients_from_10.2
     } else {
         log local0. "Node IP address is: [IP::remote_addr] and sent to SMTP_clients_from_elsewhere"
         pool SMTP_clients_from_elsewhere
     }
}
Comments
JRahm
Community Manager
Community Manager
Contributed by jeffsilverm
Version history
Last update:
‎30-Jan-2015 04:39
Updated by:
Contributors