Forum Discussion

yairsh_310893's avatar
yairsh_310893
Icon for Nimbostratus rankNimbostratus
Apr 23, 2017

Call an iRule from another iRule

Hey there

 

I'm trying to write an iRule that will do the following: create an event that will match by the client source ip address and if i come from a specific source ip address range then the irule will call another irule that will do something, otherwise (else) it will continue with the original iRule without sending me to the second iRule

 

Thanks in advance

 

4 Replies

  • Hi,

     

    If you want to run a different irule for a specific source address, you can create 2 virtual servers:

     

    • vs1 :
      • source : 0.0.0.0/0 (default value)
      • destination : vs IP address
      • irule : global irule
    • vs2 :
      • source : specific IP
      • destination : vs IP address
      • irule : specific irule

    with this configuration, vs2 will match for requests from the specific IP. all other requests will be handled by vs1.

     

    Source address only support 1 network (a single address has a mask length 32) you can create as many vs with different source address as you want.

     

  • You CAN:

     

    1) Call another virtual server from an irule

     

    2) Set a global variable to be used in another irule, but remember that TCL is event driven, so an event such as "CLIENT_CONNECT" can only be used once.

     

    3) Build the login in a monolithic irule.

     

    (3) Is nearly always the right solution.

     

    BR //Jan

     

  • Checkout the call function.

     

    For example, I use one to call an HTML page when the server farm is in "maintenance" mode.

     

     example_include.irule
    proc display_page {} {
      HTTP::respond 200 content {
          HTML code to return here

    then call it via the irule you have assigned to the VS.

     

     main.irule
    if { conditional_here } {
        call example_include.irule::display_page
    }