For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Joe_8700's avatar
Joe_8700
Icon for Nimbostratus rankNimbostratus
Jul 31, 2014

iRule for Selective Snat and Link Load Balancing

Hi All,

I just want to ask if my iRule is correct. We created a VS for outbound email with Port 25, in this VS I like to put an iRule for the condition below. 1. We have 3 ISP link gateway PLDT (x.x.x.1), Globe1 (y.y.y.3) and Globe2 (z.z.z.5) 2. For outbound email we use PLDT as primary and Globe1 as backup just in case PLDT went down so traffic will swing to Globe1 3. For the email requirement we need to SNAT the IP address of the sender to a specific IP which is x.x.x.2 for PLDT and y.y.y.4 for Globe1.

Question is my iRule below will suffice for this requirement?

when CLIENT_ACCEPTED {
    pool PLDT        choose the gateway pool first 
if { [active_members [LB::server pool]] == 0 } {     If no available pool it means PLDT is down
  snat y.y.y.4                 So snat to Globe1 and 
    pool Globe1               choose gateway from pool
} else {                else if there is available pool it means PLDT is up
  snat x.x.x.2         so snat to PLDT
pool PLDT              and choose PLDT as gateway
}
   }

Is my IRule Correct? Or I'm doing it wrong? Should I remove the pool as below?

when CLIENT_ACCEPTED {
        pool PLDT        choose the gateway pool first 
    if { [active_members [LB::server pool]] == 0 } {     If no available pool it means PLDT is down
      snat y.y.y.4                 So snat to Globe1 
    } else {                else if there is available pool it means PLDT is up
      snat x.x.x.2         so snat to PLDT
    }
       }

1 Reply

  • R_Eastman_13667's avatar
    R_Eastman_13667
    Historic F5 Account

    If you want to direct the traffic to pool Globe1 with a source IP of y.y.y.4 or PLDT with a source IP of x.x.x.2, then your first example is correct. If you want to keep the default pool assigned to the VIP, then your second example is correct.