Forum Discussion
Durga_Dash_2124
Nimbostratus
May 20, 2008Redirect 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_12Historic F5 AccountI 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] } }
- Durga_Dash_2124
Nimbostratus
Yep that works like a champ.
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