Forum Discussion
breizho35_11667
Nimbostratus
Feb 08, 2010How to read source IP and write http header ?
Hello,
since commencing in iRules, I seek your help to write a script to meet this need:
How to read source IP and write http header ?
when HTTP_Request ( ...
The_Bhattman
Nimbostratus
Feb 08, 2010Hi Eric,
The following is a untested iRule that may work for you
when HTTP_REQUEST {
Create the variable that will be used to later to store the IP address with the dots
set ipaddr
Scan command looks at the source address in [IP::client] and breaks it up into 4 variables oct1 to oct4
scan [IP::client] {%[^.].%[^.].%[^.].%s} oct1 oct2 oct3 oct4
append takes all the variables oct1 to oct4 and puts them together into another variable called ipaddr
append $ipaddr $oct1 $oct2 $oct3 $oct4
The command below inserts a header called TOTO with the value of what's in ipaddr
[HTTP::header] insert "TOTO" $ipaddr
}
I have made comments in the code so you understand the logic behind it
I hope this helps
Bhattman
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects