Hello, I’m attempting to create an iRule that will load balance based on the source IP addresses 4th octet and based on the availability of pool members. If it’s odd, I want it to redirect to http://test1.com. If it’s even, I want it to redirect to http://test2.com.
Below is the irule I created:
when CLIENT_ACCEPTED { set last [lindex [split [IP::client_addr] “.”] 3] log local0. “CLIENT IP address [IP::client_addr]” log local0. “4th octect $last” if { ($last and end_with (3,5,7,9)) } { set destination odd } else { set destination even } }
when HTTP_REQUEST { if { ( [$destination eq odd] ) and
( [active_members test01_pool] > 0 )} { HTTP::redirect http://test1.com[HTTP::uri] } elseif { ( [$destination eq odd] ) and
( [active_members test02_pool] > 0 )} { HTTP::redirect http://test2.com[HTTP::uri] } elseif { ( [$destination eq even] ) and
( [active_members test02_pool] > 0 ) } { HTTP::redirect http://test2.com[HTTP::uri] } elseif { ( [$destination eq even] ) and
( [active_members test01_pool] > 0)} { HTTP::redirect http://test1.com[HTTP::uri] } }
I keep getting the following message when I test:
Oct 31 17:43:29 bigip info tmm[13447]: Rule /Common/Med-v2 : CLIENT IP address 10.128.10.1 Oct 31 17:43:29 bigip info tmm[13447]: Rule /Common/Med-v2 : 4th octect 1 Oct 31 17:43:29 bigip err tmm[13447]: 01220001:3: TCL error: /Common/Med-v2 - invalid command name “::1” while executing “::$last end_with (3,5,7,9)”