Forum Discussion

Marvin's avatar
Marvin
Icon for Cirrocumulus rankCirrocumulus
Oct 24, 2019

Load balance decision based on client IP and datagroup value

I want to load balance traffic to a specific pool member based on the Source IP that is connecting to the VIP. I created the following Irule for that and a datagroup.

The datagroup contains for example the following values. So client IP 10.0.0.1 needs to be load balanced to 192.168.0.1 and the other to .2 etcetera, this also with a fallback if there is not match.

Client IP Pool member IP

10.0.0.1 192.168.0.1

10.0.0.2 192.168.0.2

Is this the correct syntax or am I missing something here?

when CLIENT_ACCEPTED {
set key [class match -name [IP::client_addr] contains Datagroup]
set value [class match -value $key contains Datagroup]

if { $value ne "" } {
pool serverpool member $value 80

} else
{
pool serverpool
}
}
  • when CLIENT_ACCEPTED {
     
    set clientip [IP::client_addr]
    set value [class lookup $clientip Datagroup]
     
    if { $value ne "" } {
     
    pool serverpool member $value 80
     
    } else
     
    {
    pool serverpool
    }
    }
  • Marvin's avatar
    Marvin
    Icon for Cirrocumulus rankCirrocumulus
    when CLIENT_ACCEPTED {
     
    set clientip [IP::client_addr]
    set value [class lookup $clientip Datagroup]
     
    if { $value ne "" } {
     
    pool serverpool member $value 80
     
    } else
     
    {
    pool serverpool
    }
    }