iRules Development Environment

Problem this snippet solves:

You want to write iRules on your own system and save them into some source control repo (git) then you need some tools. You could look at the old and out of date iRules Editor but want you really want is something more powerful.


You want an IDE!! You need VSCode (Visual Studio Code)

How to use this snippet:

How to setup VSCode for iRule development

Download and install VSCode, if you are on Windows system recommend the User Installer over the System Installer


Once installed you will need some Extensions, click on the Extensions icon on the and search for the following extensions or click on the links below to open the VisualStudio Marketplace where you can click on the Install button.


Recommended Extensions:


You can now open up a folder and create some files and write some iRules.


VSCode help (https://code.visualstudio.com/docs)

Git help (http://think-like-a-git.net/)


For a central Git repo recommand GitHub or GitLab


Code :

Example iRule file named logTime.tcl:

ltm rule logTime {
    when CLIENT_ACCEPTED {
        set timeInMilliseconds [clock clicks -milliseconds]
        log local0.info "TCP connection started at [clock format [expr {$timeInMilliseconds / 1000}] -format "%H:%M:%S" -gmt true].[format {%03u} [expr {$timeInMilliseconds % 1000}]] for IP [IP::client_addr]"
    }

    when HTTP_REQUEST {
        set timeInMilliseconds [clock clicks -milliseconds]
        log local0.info "HTTP Reqest at [clock format [expr {$timeInMilliseconds / 1000}] -format "%H:%M:%S" -gmt true].[format {%03u} [expr {$timeInMilliseconds % 1000}]] for IP [IP::client_addr] and URI [HTTP::uri]"
    }
}

Tested this on version:

No Version Found
Published May 23, 2019
Version 1.0