Forum Discussion

kirk_stanford_5's avatar
kirk_stanford_5
Icon for Nimbostratus rankNimbostratus
Sep 23, 2014

iRule redirect to URI based on source network

I need to redirect most internal RFC 1918 networks to a URL and then everything else redirect to a different URL. The specifics are below:

 

If one of these networks:

 

10.0.0.0/8

 

192.168.0.0/16

 

172.16.0.0/16

 

172.18.0.0/16

 

172.19.0.0/16

 

172.20.0.0/16

 

172.21.0.0/16

 

172.22.0.0/16

 

172.23.0.0/16

 

172.24.0.0/13

 

Go to URL http://www.somewebsite.com/internal.html

 

All else go to URL http://www.somewebsite.com/external.html

 

Thanks for the help.

 

Kirk Stanford

 

  • shaggy's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus

    Verify that the "private_net" data group exists on your F5 ( Local Traffic | iRules | Data Group List ) and that it contains the IP addresses you expect.

    when HTTP_REQUEST {
        if { [class match [IP::client_addr] equals private_net } {
            HTTP::redirect "http://www.somewebsite.com/internal.html"
        } else {
            HTTP::redirect "http://www.somewebsite.com/external.html"
    }
    

    The following post has more options/discussion regarding redirecting based on client IP: https://devcentral.f5.com/questions/irule-redirect-based-on-client-ip-address

  • Thank you very much for the help. I will configure on my test environment.

     

    Best Regards,

     

    Kirk