Forum Discussion

raphael_norber1's avatar
raphael_norber1
Icon for Nimbostratus rankNimbostratus
Sep 16, 2006

redirect on IP addy

im trying to do a simple rule. i want to specify multiple ip addresses/ranges that will goto a pool, and everyone else redirected to a different site. im trying to use "or" to add multiple ranges, but my syntax is messed up somewhere. below is my rule. ultimately, it would be nice to create a list of some kind and be able to add/remove ips from the list rather than joining a bunch with or's. much appreciate any help:

 

 

when HTTP_REQUEST {

 

 

if { (not [IP::addr [IP::client_addr] equals 10.2.1.0/255.255.255.0]) or

 

(not [IP::addr [IP::client_addr] equals 10.1.6.0/255.255.255.0]) } {

 

 

HTTP::redirect "http://sitedown.website.com/sitedown.html"

 

} else {

 

pool www

 

}

 

}
  • ok, i figured out the datagrups concept...i think.

     

     

    i now have the following rule, but i get a page cant be displayed when i goto the site thats in the datagroup. am i stuck in some kind of loop?

     

     

    when HTTP_REQUEST {

     

     

    if { (not [ matchclass [IP::client_addr] equals $::data_sitedown ] ) } {

     

     

    HTTP::redirect http://sitedown.select2perform.com/sitedown.html"

     

     

    } else {

     

     

    pool select2perform-AP

     

    }

     

    }
  • haha. i found my own error. i feel like an idiot. missing " in front of the url i wanted to redirect to! wierd that the irules editor didnt catch it. i think im all set! Thanks to everyone on this forum, this is a great help for those of us infrastructure dorks that cant program ourselves out of a wet paper bag!
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    It probably didn't catch it because you don't need the quotes for that command. You can supply the string with or without it.

     

     

    Interesting though, that it didn't find an unmatched quote as a problem, you're right.

     

     

    Colin