Forum Discussion
ant77
Cirrostratus
Jul 01, 2020Alternative to getfield to check XFF client IP using data group
Hi All, We ran into a bug when upgrading to 13.1.3.3 that process an iRule to check the client IP address in an XFF header against what is defined in a data group "DG-ALLOWED-IP". Is there an...
Jim_Deucker
Employee
Jul 02, 2020Here's an old proc for sorting this down
proc get_xff_ip {{xff_hdr {X-Forwarded-For}}} {
foreach ip "[string map {- { } \{ { } \} { } , { } \[ { } \] { } \" { } \( { } \) { } ; { } \$ { } # { } \\ { }} [HTTP::header values $xff_hdr]] [IP::client_addr]" {
if {![catch {IP::addr $ip mask ::}]} {
if {![IP::addr $ip equals 127.0.0.0/8] && ![IP::addr $ip equals 0.0.0.0/32] && ![IP::addr $ip equals ::/127]} {
return $ip
}
}
}
}This returns the first non-localhost, non bogon 0.0.0.0 valid IP address in either the specified header or the client's IP.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
