Forum Discussion
panos_101277
Nimbostratus
Apr 29, 2008Multiple irules using same local variable name
Hello,
First off thanks to all the contributors for their many examples and tips, it has really helped a lot.
My question is a simple one but I haven't been able to find an answer ...
hoolio
Cirrostratus
Apr 29, 2008Hi,
Global variables (like $::my_var) are shared across all iRules on all VIPs on all TCP connections. Local variables (like $my_var) are shared across the same TCP connection for any iRule(s) associated with the same virtual server. So if you set myvar in rule1 on vip1 and add a second rule to vip1, that same variable instance is accessible (and can be trampled) in rule2. If you want distinct local variable instances on multiple rules on the same VIP, you can name them uniquely. Using unique variable names per VIP is also important for global variables if you don't want other rules to be able to impact a separate rule. A good example of this is using a global debug variable. You probably wouldn't want debug enabled in every rule if you change the global variable in a single rule. So you can use a naming convention that includes the rule name or application (like ::irule1_debug instead of ::debug).
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects