Irules 101 01 Introduction to Irules

March 25, 2018 | Author: Kishore Kumar | Category: Hypertext Transfer Protocol, Software Engineering, Computing, Technology, Computer Programming


Comments



Description

iRules 101 - #01 - Introduction to iRulesJoe Pruitt, 2007-01-11 Introduction An iRule is a powerful and flexible feature of BIG-IP devices based on F5's exclusive TMOS architecture. iRules provide you with unprecedented control to directly manipulate and manage any IP application traffic. iRules utilizes an easy to learn scripting syntax and enables you to customize how you intercept, inspect, transform, and direct inbound or outbound application traffic. In this series of tech tips, we'll talk about the TCL language, it's usage and control structures, as well as iRule extensions to the TCL language. Other articles in the series: iRules 101 – #01 – Introduction to iRules iRules 101 – #02 – If and Expressions iRules 101 – #03 – Variables iRules 101 – #04 – Switch iRules 101 – #05 – Selecting Pools, Pool Members, and Nodes iRules 101 – #06 – When iRules 101 – #07 – Catch iRules 101 – #08 – Classes iRules 101 – #09 – Debugging iRules 101 – #10 – Regular Expressions iRules 101 – #11 – Events iRules 101 – #12 – The Session Command iRules 101 – #13a – Nested Conditionals iRules 101 – #13b – TCL String Commands Part 1 iRules 101 – #14 – TCL String Commands Part 2 iRules 101 – #15 – TCL List Handling Commands iRules 101 – #16 – Parsing String with the TCL Scan Command iRules 101 – #17 – Mapping Protocol Fields with the TCL Binary Scan Command Components of an iRule An iRule consists of one or more event declarations, each containing TCL code that is executed when that event occurs. First, it will be helpful to explain what an event is. Event An event is an extension to TCL that F5 has added to facilitate modular based programming. Between the time when a connection flows into TMOS, and out the other side, there are a series of internal states that are reached by that connection. Each of these states equate to an event in the iRule language. These states, such as CLIENT_ACCEPTED, can occur globally in scope (meaning they happen for all connections regardless of which profiles are applied to the virtual servers). Or they can be profile specific (HTTP_REQUEST, CLIENTSSL_CLIENTCERT, RTSP_RESPONSE, ...) meaning that their states are only reached if a certain profile is assigned to the virtual server. An event is declared using the F5-added "when" statement.  when EVENT_NAME { TCL‐CODE } For a list of the available events, refer to the iRule Events wiki document. The key benefit to take away from events is that they allow iRules to be broken into logical pieces and executed in a non- Basically. or encrypting data with an AES key (AES::encrypt).). and "ends_with" have been added to act as helpers for common comparisons. In TCL. A list of the iRules added/enhanced operators can be found here. Several commands within the TCL language have been disabled in the iRules implementation. essentially everything is considered a command. or "pool" to assign a load balancing decision to a specified pool of servers. and commands.). and commands? What is "default" in the switch statement? What happens with the Content-Length header is empty in the HTTP Response? pool num . The TCL language can be broken down into operators and commands. most often.. With commands. Statements Statements are commands that typically don't return a value. Putting it all together The following iRule contains several events. The extensive list of commands are documented in the iRules Commands wiki document. and commands. or you could use the iRules specific statement "log" to log messages to the system log. functions. We've taken the various commands and segmented them into three types: functions. In addition to the standard TCL command set. when HTTP_REQUEST { if { [HTTP::uri] starts_with "/foobar" } { switch ‐glob [HTTP::uri] { "*[0‐9].. basically. statements. and "substr" assist in working with strings. A list of disabled commands can be found here. A full list of F5 added functions are on the iRules functions wiki document. SIP::call_id. procedures. operators. >=. functions. any command that could cause an unexpected halt in the traffic flow (file IO. F5 has added additional commands that are either global in scope (TCP::client_port.j Questions Can you identify all operators. operators such as "starts_with". When you compare two values.. The full list of commands can be found in the command section of the iRules wiki.. . return a value.. The purpose of a statement is. statements.sourceforge. TCL iRules use a TCL runtime engine to execute the script logic. "contains". Functions Functions are utility commands that. . while "findstr".) or specific to a certain profile (HTTP::uri. Functions like "findclass" and "matchclass" assist in Data Group access. you will use an operator to do the comparison. You can use TCL's "if" and "switch" statements to perform conditional tests.net/doc/tcl/index. to "do something"... "getfield". This means that only the code for a specific event is executed when that event occurs.html.) have been removed.For a list of the available events. A full list of iRules specific statements can be found in the iRules Statements wiki document. In addition to the builtin TCL operators (==. Operators An operator is a token that "operates" on other values. Socket calls. . refer to the iRule Events wiki document. Commands Commands are pretty much every other control structure you can use within TCL. The key benefit to take away from events is that they allow iRules to be broken into logical pieces and executed in a nonserial manner. IP::addr. statements. <=. The documentation for the TCL language can be found at http://tmml. you can do things like getting the URI of a HTTP Request (HTTP::uri). .. com F5 Networks Japan K.Can you identify all operators. in the U. Seattle.html Get the Flash Player to see this player.html iRules Events . functions.f5.com F5 Networks Ltd.com.aspx/iRules. services.f5. and commands? Conclusion In this article. statements.S.f5.com F5 Networks.com ©2016 F5 Networks.com F5 Networks Asia-Pacific apacinfo@f5. and in certain other countries.http://tmml.Commands iRules Operators .aspx/iRules. WA 98119 | 888-882-4447 | f5.Statements iRules Commands . we'll dig deeper into the various components of iRules and how to make best use of those features.f5.aspx/iRules. All rights reserved.Operators Disabled TCL Commands . and commands? What is "default" in the switch statement? What happens with the Content-Length header is empty in the HTTP Response? What's the difference with -glob in a switch statement and a full blown regular expression? When do you need to use brackets around functions.com/wiki/default.com/wiki/default. statements.net/doc/tcl/index.K. claimed by F5.Events iRules Functions . Europe/Middle-East/Africa emeainfo@f5. Inc. and the F5 logo are trademarks of F5 Networks. Inc.https://devcentral.com/wiki/default.aspx/iRules. | 401 Elliot Avenue West. Inc. F5 Networks. Other F5 trademarks are identified at f5.https://devcentral. CS04-00015 0113 .https://devcentral.f5.aspx/iRules. Links TCL Reference . or company names referenced herein may be trademarks of their respective owners with no endorsement or affiliation. F5 Networks. f5j-info@f5. Any other products.Functions iRules Statements .com/wiki/default. Corporate Headquarters info@f5. we've gone over the basic components of the iRules language.sourceforge. express or implied. In future articles in this series. Inc.https://devcentral. F5.com/wiki/default.aspx/iRules/DisabledTclCommands.https://devcentral.https://devcentral.com/wiki/default.f5.
Copyright © 2024 DOKUMEN.SITE Inc.