F5 LTM - iRule Variables

The F5 offers a number of different ways to you can represent your data via iRules such as variables, tables, datagroups and arrays. Within this article we will look at the variables. There are 2 main types of variables, local and global.


Local variables represent data within your local namespace, and are assigned the same scope as the iRule that created it. This also means that local variables are shared across all iRules for a Virtual Server. In addition to this local variables are also session based.

Below shows you how you would assign, output and unassign a local variable.

set uri "picture.jpg"     <- assign var
log local0. "uri is $uri" <- output var
unset uri                 <- unassign var


Unlike local variables, global variables exist outside of the local namespace, meaning that they aren't bound to a single session but instead a TMM instance. An example of when a global variable may be required would be the assignment of an IP address to a variable that you would want available to every session across the F5 system.

Unfortunately global variables are not shared across TMM instances and are only available globally within the local TMM instances. Because of this using a global variable within an iRule demotes CMP (Clustered Multi-Processing) from the associated virtual server.

set ::uri "picture.jpg"     <- assign var
log local0. "uri is $::uri" <- output var
unset ::uri                 <- unassign var

Static Global

Static global variables overcome the CMP demotion problem by sharing the data across each TMM instance. However as the name suggests the variable is static, and is only defined each time the iRule is initialized. 

when RULE_INIT {
  set static::debug 0

  if { $static::debug } {
    log local0. "debug equals $static::debug"


Tags: TCL, iRule, BIG-IP F5

About the Author


R Donato

Rick Donato is the Founder and Chief Editor of He currently works as an SDN/NFV Solutions Architect and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001