Forum Discussion
CraigWoo
Sep 24, 2022Nimbostratus
simple redirect irule based off ip
Hi All I am very new to irules as we just got our first big-ip this week and have a rookie question for you. I'm trying to redirect a sub-section of a site that I have got working with when HTTP_R...
- Sep 26, 2022
Hello, how many networks do you need to match?
For allowing multiple client networks you'll need a data group.
See this example below - note that "getfield" returns a string so I'm changing the format to IP address using IP::addr .
when HTTP_REQUEST { if {[string tolower [HTTP::uri]] starts_with "/restricted1" }{ if { [IP::addr [getfield [IP::client_addr] "%" 1] equals "10.2.2.0/24"]}{ #this is a sample with a static client network return } elseif { [class match [getfield [IP::client_addr] "%" 1] equals datagroup_allowed_networks] } { #when you have multiple subnet to match, then it is recommended to use data-group created as Address (IP) type. return } else { HTTP::redirect "https://demo.com/not-allowed" } }
CraigWoo
Oct 25, 2022Nimbostratus
Thanks, Have updated now. this worked in the lab for our ECP portal
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] starts_with "/ecp"}{
if { [class match [getfield [IP::client_addr] "%" 1] equals ecp-access] }{
#this is a sample with a static client network
return
} else {
HTTP::redirect "https://wwww.testwebsite.com/not-allowed"
}
}
}
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