Forum Discussion

Durga_Dash_2124's avatar
Durga_Dash_2124
Icon for Nimbostratus rankNimbostratus
May 20, 2008

Redirect to URL

I want to be able to write an iRule that will redirect traffic from the virtual server to an IP address which has its first three octets fixed but the last octet comes from the last octet of the virtual server.

 

e.g. We are migrating our network from the 10.40.40.0/24 subnet to the 10.50.50.0/24 subnet. Since DNS is on several customer networks we want to be able to repoint all DNS entries currently pointing to 10.40.40.0/24 in advance to 10.50.50.0/24. Since the actual sites have not been migrated yet we put a big-ip (9.2.5 LTM) on the 10.50.50.0/24 subnet with redirect rules to redirect traffic to 10.40.40.0/24.

 

 

Our IP migration rule is simple every website on 10.40.40.X becomes 10.50.50.X. So the 4th octet is the same between both networks.

 

 

So on the BIGIP i created a network virtual server 10.50.50.0/24 and put a redirect irule on it.

 

Here is my rule now..redirecting everything to 10.40.40.1. but i want to be able to redirect 10.50.50.x to 10.40.40.X

 

----------------------------------

 

when HTTP_REQUEST {

 

log local0. "in HTTP_REQUEST"

 

if { matchclass [IP::local_addr] equals $::TenFiftyZeroSubnet }

 

HTTP::redirect http://10.40.40.1[HTTP::uri]

 

}

 

 

class TenFiftyZeroSubnet {

 

network 10.50.50.0 mask 255.255.255.0

 

}

 

----------------------------------

 

 

Can you guys show me how to redirect 10.50.50.x to 10.40.40.x in one irule ? instead of writing 255 irules?
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    I think what you're looking for is:

     
     when HTTP_REQUEST { 
       log local0. "in HTTP_REQUEST" 
       if { matchclass [IP::local_addr] equals $::TenFiftyZeroSubnet } { 
         HTTP::redirect http://10.40.40.[getfield [IP::local_addr] . 4][HTTP::uri] 
       } 
     }  
     

    This will grab the last octet of the incoming IP address and keep it static, while updating the first 3 octets to the new address.

    Hope this helps,

    Colin