Forum Discussion

Tom_89796's avatar
Tom_89796
Icon for Nimbostratus rankNimbostratus
Jun 14, 2012

Route Domain and IP::Client_addr

Running 10.2.3 LTM with multiple route domains for DR. For one of the Virtual IP's we run the following iRule to capture the requesting IP address and append it to the URI. Problem is the IP::client_addr is returned with the appended %1 as this route domain is not the default. That being the case the appending IP::client_addr is including the route domain which is breaking the application.

 

 

Is there a way to drop to trailing %rd from the IP Address?

 

 

 

when HTTP_REQUEST {

 

set client [IP::client_addr]

 

set request [HTTP::uri]

 

if {$request contains "login.aspx" and $request contains "?"}

 

{HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]"}

 

elseif {$request contains "login.aspx"}

 

{HTTP::uri "[HTTP::uri]?IPAddress=[IP::client_addr]"}

 

elseif {$request contains "ACCGateway.aspx" and $request contains "?"}

 

{HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]"}

 

elseif {$request contains "login2.aspx"}

 

{HTTP::uri "[HTTP::uri]?IPAddress=[IP::client_addr]"}

 

elseif {$request contains "login2.aspx" and $request contains "?"}

 

{HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]"}

 

}when HTTP_REQUEST {

 

set client [IP::client_addr]

 

set request [HTTP::uri]

 

if {$request contains "login.aspx" and $request contains "?"}

 

{HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]"}

 

elseif {$request contains "login.aspx"}

 

{HTTP::uri "[HTTP::uri]?IPAddress=[IP::client_addr]"}

 

elseif {$request contains "ACCGateway.aspx" and $request contains "?"}

 

{HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]"}

 

elseif {$request contains "login2.aspx"}

 

{HTTP::uri "[HTTP::uri]?IPAddress=[IP::client_addr]"}

 

elseif {$request contains "login2.aspx" and $request contains "?"}

 

{HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]"}

 

}

 

2 Replies

  • Hi Tom,

     

     

    You can use getfield to parse the IP address from an IP%rd value:

     

     

    https://devcentral.f5.com/wiki/iRules.getfield.ashx

     

    set ip [getfield [IP::client_addr] % 1]

     

     

    Here's an optimized version of your code:

     

     

    when HTTP_REQUEST {
    switch -glob [string tolower [HTTP::uri]] {
    "*login.aspx" -
    "*login2.aspx" -
    "*accgateway.aspx" {
    HTTP::uri "[HTTP::uri]?IPAddress=[getfield [IP::client_addr] % 1]"
    }
    "*login.aspx\?*" -
    "*login2.aspx\?*" -
    "*accgateway\?*" {
    HTTP::uri "[HTTP::uri]&IPAddress=[getfield [IP::client_addr] % 1]"
    }
    }
    }
    

     

     

    Aaron