Forum Discussion
hooleylist
Oct 21, 2009Cirrostratus
Can you give this a try? The only significant changes I made were to remove the IP::addr command from the switch statement and add logging. I also remove the $:: prefix from the class names to make the iRule CMP compatible. For more info on this, you can check this CMP page (Click here).
when CLIENT_ACCEPTED {
log local0. "[IP::client_addr]:[TCP::client_port]: New connection to [IP::local_addr]:[TCP::local_port]"
Check if client IP is in the cns_class
if {[matchclass [IP::local_addr] equals cnc_class]}{
pool cnc_ratio_pool
log local0. "[IP::client_addr]:[TCP::client_port]: Matched client to cnc_class"
Check if destination IP is in the ct_class
} elseif {[matchclass [IP::local_addr] equals ct_class]}{
pool ct_ratio_pool
log local0. "[IP::client_addr]:[TCP::client_port]: Matched destination to ct_class"
} else {
pool cnc_ratio_pool
log local0. "[IP::client_addr]:[TCP::client_port]: Default case."
}
}
when LB_SELECTED {
Check if client is 172.16.3.0/24
if {[IP::addr [IP::client_addr]/24 equals 172.16.3.0]}{
log local0. "[IP::client_addr]:[TCP::client_port]: Matched client check for 172.16.3.0/24"
Check selected pool member IP
switch {[LB::server addr]}{
"221.218.248.145" {
snatpool snat_ct_mail
log local0. "[IP::client_addr]:[TCP::client_port]: Matched destination IP 221.218.248.145. Snatting using snat_ct_mail"
}
"222.35.42.97" {
snatpool snat_cnc_mail
log local0. "[IP::client_addr]:[TCP::client_port]: Matched destination IP 221.218.248.145. Snatting using snat_cnc_mail"
}
}
} else {
snat $snat_cnc_default
log local0. "[IP::client_addr]:[TCP::client_port]: Didn't match client check for 172.16.3.0/24. Snatting using snat_cnc_mail"
}
}
Aaron