Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

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

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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]
}
0
Comments on this Answer
Comment made 1 month ago by rickylev 64

that's perfect, thanks

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

This should remove anything after the '%' sign

when HTTP_REQUEST {
     HTTP::header insert CLIENTIP [regsub {%.*} [IP::client_addr] ""]}
0
Comments on this Answer
Comment made 1 month ago by rickylev 64

too easy, thank you sir

0