Forum Discussion
John_Giannone_4
Nimbostratus
Jun 09, 2008IRules for Redirection on GTM
We are currently using a GTM 1500 to redirect incoming web traffic based on Geographic locaiton. So when someone comes to our mainsite (for example) and they are from Australia, we serve them the IP of our domain.au site. For this we are using Regions and Topology records. Woroks great.
We want to change to IRules however, so we can redirect customers for several different wide IPs. The IRule we have configued per DEV central is as follows, however, I am told by F5 that it doesnt work and there may be a bug:
when DNS_REQUEST {
if {[whereis [IP::remote_addr]] contains "US"} {
pool raileurope_us_pool
}
if {[whereis [IP::remote_addr]] contains "AU"} {
pool raileurope_au_pool
}
if {[whereis [IP::remote_addr]] contains "JP"} {
pool raileurope_jp_pool
}
if {[whereis [IP::remote_addr]] contains "ZA"} {
pool raileurope_sa_pool
}
if {[whereis [IP::remote_addr]] contains "BO"} {
pool raileurope_bolivia_pool
}
if {[whereis [IP::remote_addr]] contains "CL"} {
pool raileurope_chile_pool
}
if {[whereis [IP::remote_addr]] contains "CO"} {
pool raileurope_columbia_pool
}
if {[whereis [IP::remote_addr]] contains "EC"} {
pool raileurope_ecuador_pool
}
if {[whereis [IP::remote_addr]] contains "PY"} {
pool raileurope_paraguay_pool
}
if {[whereis [IP::remote_addr]] contains "PE"} {
pool raileurope_peru_pool
}
if {[whereis [IP::remote_addr]] contains "UY"} {
pool raileurope_uruguay_pool
}
if {[whereis [IP::remote_addr]] contains "VE"} {
pool raileurope_venezuela_pool
} else {
pool raileurope_us_pool
}
}
I am told by F5 that the following IRule does work. Is there a better way to write it though:
when DNS_REQUEST {
set wherefrom [whereis [IP::remote_addr]]
if {$wherefrom ends_with "US"} {
pool raileurope_us_pool
} elseif {$wherefrom ends_with "AU"} {
pool raileurope_au_pool
} elseif {$wherefrom ends_with "JP"} {
pool raileurope_jp_pool
} elseif {$wherefrom ends_with "ZA"} {
pool raileurope_sa_pool
} elseif {$wherefrom ends_with "BO"} {
pool raileurope_bolivia_pool
} elseif {$wherefrom ends_with "CL"} {
pool raileurope_chile_pool
} elseif {$wherefrom ends_with "CO"} {
pool raileurope_columbia_pool
} elseif {$wherefrom ends_with "EC"} {
pool raileurope_ecuador_pool
} elseif {$wherefrom ends_with "PY"} {
pool raileurope_paraguay_pool
} elseif {$wherefrom ends_with "PE"} {
pool raileurope_peru_pool
} elseif {$wherefrom ends_with "UY"} {
pool raileurope_uruguay_pool
} elseif {$wherefrom ends_with "VE"} {
pool raileurope_venezuela_pool
} else {
pool raileurope_us_pool
}
}
- The_Bhattman
Nimbostratus
I haven't ever written any iRules to take advantage of GTMwhen DNS_REQUEST { set wherefrom [whereis [IP::remote_addr]] switch -glob $wherefrom { "*US" { pool raileurope_us_pool } "*AU" { pool raileurope_au_pool } "*JP" { pool raileurope_jp_pool } . . . default { raileurope_us_pool } } }
- hoolio
Cirrostratus
cmbhatt's suggestion of using a switch is definitely a good one. Did F5 provide you with a CR number describing the bug? It seems odd that saving the output from [whereis [IP::remote_addr]] would make any difference versus using the commands in every line. The former option would be more efficient (with a switch being even better), but they should be functionally the same. - John_Giannone_4
Nimbostratus
NO CR number, they arent even sure it is a bug. They couldn't get the IRule to work, so were going to escalate it.
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