cancel
Showing results for 
Search instead for 
Did you mean: 

url redirect based on client IP address range

Greg_Hammond
Nimbostratus
Nimbostratus

I have written the following irule to redirect http requests based on IP address ranges but the user says it isn't working. Just need a little help verifying that the syntax is correct or if I am missing anything.

 

when HTTP_REQUEST {

  if { [IP::addr [IP::client_addr] equals 10.10.10.0/24] }{ HTTP::redirect "http://www.site1.com/ibs/Pages/ca_en.aspx" }

  elseif { [IP::addr [IP::client_addr] equals 10.10.11.0/24] }{ HTTP::redirect "https://www.site2.com/scripts/index.aspx/bpg/travel/pages/Concur" }

 }

 

There are only 2 ranges that need to be redirected. If an IP is not in either of these ranges, it should just fail which is why there is no "drop out" rule.

 

Thanks in advance.

1 REPLY 1

Samir
Nacreous
Nacreous

Put additional log statements and see whether traffic is coming to your irule or not.

 

Monitor the logs. it will give some clue

 

when HTTP_REQUEST { log local0. "Client IP address is - [IP::client_addr]:[TCP::client_port]" if { ( [IP::addr [IP::client_addr] equals 10.10.10.0/24] ) } { log local0. "Client IP address is - [IP::client_addr]:[TCP::client_port]" HTTP::redirect "ttp://www.site1.com/ibs/Pages/ca_en.aspx" } elseif { ( [IP::addr [IP::client_addr] equals 10.10.11.0/24] ) } { log local0. "Client IP address is - [IP::client_addr]:[TCP::client_port]" HTTP::redirect "https://www.site2.com/scripts/index.aspx/bpg/travel/pages/Concur" } }