LDAP Pool Selection By IP For Mobile Devices

Problem this snippet solves:

Distributes traffic to different pools based on LOGIN-IP address in LDAP request data.

First define the classes (Data Group Lists) as type "Address", adding the appropriate addresses to each.

Then apply the iRule to the virtual server, and it will distribute the traffic to each pool depending on the LOGIN-IP value.

Code :

# Data Group Lists

class AddressGroupA {
  "network 10.16.13.0/26"
  "host 10.10.10.1"
}

class AddressGroupB{
  "network 10.16.13.64/26"
  "host 10.10.10.2"
}

# iRule Source

when RULE_INIT {
  set ::defaultPool myPool
}
when CLIENT_ACCEPTED {
  TCP::collect
}
when CLIENT_DATA {
  set LoginIP [findstr [TCP::payload] LOGIN-IP 9 "MSISDN"]
  if {$LoginIP != ""}{
    if { [matchclass $LoginIP equals $::AddressGroupA]}{
      pool PoolA
    } elseif { [matchclass $LoginIP equals $::AddressGroupB]}{
      pool PoolA
    }
  } else {
    pool $::defaultPool
  }
  TCP::release
}
Published Mar 18, 2015
Version 1.0
No CommentsBe the first to comment