Forum Discussion
Strip route domain from ip::remote_addr
Hello.
Trying to create an irule and when using ip::remote_addr, it is adding the %rd to the IP address. I am fairly new to irules, but wondering if that route domain designation can be stripped from the value before putting it into the http header.
There are a number of ways of doing that, but here is one (though untested!) that should work:
when HTTP_REQUEST { HTTP::header insert X-Some-Header "[getfield [IP::client_addr] % 1]" }
For more information on
:getfield
I also encourage, for header insertion, that you consider using Local Traffic Policies, if possible:
- VernonWellsEmployee
There are a number of ways of doing that, but here is one (though untested!) that should work:
when HTTP_REQUEST { HTTP::header insert X-Some-Header "[getfield [IP::client_addr] % 1]" }
For more information on
:getfield
I also encourage, for header insertion, that you consider using Local Traffic Policies, if possible:
- John_Bartoldus_NimbostratusThis worked nicely. Thanks. Just curious, why Local Traffic Policies instead of iRule? Both in my initial training and F5 professional services recommended iRules instead of Local Traffic Policies. But, that could have been for personal reasons. I am curious to hear pros and cons of each.
- Vernon_97235Historic F5 Account
There are a number of ways of doing that, but here is one (though untested!) that should work:
when HTTP_REQUEST { HTTP::header insert X-Some-Header "[getfield [IP::client_addr] % 1]" }
For more information on
:getfield
I also encourage, for header insertion, that you consider using Local Traffic Policies, if possible:
- John_Bartoldus_NimbostratusThis worked nicely. Thanks. Just curious, why Local Traffic Policies instead of iRule? Both in my initial training and F5 professional services recommended iRules instead of Local Traffic Policies. But, that could have been for personal reasons. I am curious to hear pros and cons of each.
- VernonWellsEmployee
Local Traffic Policies are part of the standard configuration, and as a consequence, are generally easier to operationalize, replicate and are better supported by F5. Moreover, built-in functions are usually faster than iRules because they are less generic. Having said that, of course, there are some functions that cannot be performed with Local Traffic Policies, and in those cases, iRules are the way to go.
- John_Bartoldus_Nimbostratus
Thanks for your answers. Appreciate it.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com