iRules overview

An iRule is a powerful and flexible feature within the BIG-IP® local traffic management system that you can use to manage your network traffic. Using syntax based on the industry-standard Tools Command Language (Tcl), the iRulesTM feature not only allows you to select pools based on header data, but also allows you to direct traffic by searching on any type of content data that you define. Thus, the iRules feature significantly enhances your ability to customize your content switching to suit your exact needs.

Basic iRule elements

iRules are made up of these basic elements:

  • Event declarations
  • Operators
  • iRule commands

Event declarations

iRules are event-driven, which means that the BIG-IP system triggers an iRule based on an event that you specify in the iRule. An event declaration is the specification of an event within an iRule that causes the BIG-IP system to trigger that iRule whenever that event occurs. Examples of event declarations that can trigger an iRule are HTTP_REQUEST, which triggers an iRule whenever the system receives an HTTP request, and CLIENT_ACCCEPTED, which triggers an iRule when a client has established a connection.

Operators

An iRule operator compares two operands in an expression. In addition to using the Tcl standard operators, you can use the operators listed below

Operator
Syntax
Relationaloperators
contains
matches
equals
starts_with
ends_with
matches_regex
Logicaloperators
not
and
or

iRule commands

An iRule command within an iRule causes the BIG-IP system to take some action, such as querying for data, manipulating data, or specifying a traffic destination. The types of commands that you can include within iRules are:

  • Statement commands – These commands cause actions such as selecting a traffic destination or assigning a SNAT translation address. An example of a statement command is pool , which directs traffic to the named load balancing pool. For more information, see Using iRule commands.
  • Commands that query or manipulate data – Some commands search for header and content data, while others perform data manipulation such as inserting headers into HTTP requests. An example of a query command is IP::remote_addr, which searches for and returns the remote IP address of a connection. An example of a data manipulation command is HTTP::header remove , which removes the last occurrence of the named header from a request or response.
  • Utility commands – These commands are functions that are useful for parsing and manipulating content. An example of a utility command is decode_uri , which decodes the named string using HTTP URI encoding and returns the result. For more information on using utility commands, see Utility commands.