Interpret a string as an IP address
The background is I have two virtual servers, one fort port 80 traffic and the other for port 443 traffic. Both are using different pools with the same nodes, but different ports. Here is my iRule:
---------------------------------------------
when HTTP_REQUEST {
set setCookie 0
if { [HTTP::cookie exists "cPersist"] } {
set nodeIP "[b64decode [HTTP::cookie value cPersist]]"
pool [LB::server pool] member $nodeIP
} else {
set setCookie 1
}
}
when HTTP_RESPONSE {
if { $setCookie equals "1" } {
HTTP::cookie insert name "cPersist" value [b64encode [IP::remote_addr]]
HTTP::cookie expires "cPersist" 3600
}
}
---------------------------------------------
The goal is simple, I'm trying to create an iRule that will persist based off the node IP address which initially served the request. To avoid the node IP address being available publically, I'm doing a simple base64 encode/decode on the value to obfuscute it.
The issue, I don't think the "pool" command is properly telling the F5 what should be set. I'm seeing my connection bounce between two servers. When removing the base64 encoding/decoding, however, everything seems to work just fine. The theory is when the string has been base64 decoded, it may be an IP address, but TCL is interpretting it as a string.
So, my question then, is simply this, how do you instruct the F5 to interpret a string as an IP address?
If I'm missing anything else blatently in my iRule, please let me know.
Thanks.
-Eddie