Forum Discussion

rickylev_247499's avatar
rickylev_247499
Icon for Nimbostratus rankNimbostratus
Mar 13, 2019

Solved - Remove Route Domain from iRule output

Hello, I have a test VIP that i've added an iRule to insert a custom header with the client IP, similarly to an X-Forwarded-For header (but with a custom name). The issue i'm running into is that the Bridge Domain number is being appended to the string.

ex: 1.1.1.1%111

i'm looking for a way to remove the "%111" from the string and insert the IP only in the header.

here is the iRule I have set:

when HTTP_REQUEST {
     HTTP::header insert CLIENTIP [IP::client_addr]
}

I understand this is the default behavior for VIPs on the default partition.

sorry if i missed any articles that explain this, unfortunately my search didn't turn up anything iRule specific.

thanks in advance

2 Replies

  • This should remove anything after the '%' sign

    when HTTP_REQUEST {
         HTTP::header insert CLIENTIP [regsub {%.*} [IP::client_addr] ""]}
    
  • You can use the

    getfield
    command to strip out the route domain ID appended to the client IP:

    when HTTP_REQUEST {
        HTTP::header insert CLIENTIP [getfield [IP::client_addr] "%" 1]
    }