Forum Discussion
Mariusz_B
Nimbostratus
Feb 17, 2015iRule - wrong variable definition ?
Hi all,
I have the following iRule, which in terms of syntax is fine:
when DNS_REQUEST {
switch [IP::remote_addr] {
"10.10.1.32/27" -
"10.10.1.64/27" -
"10.10.1.16...
Mariusz_B
Nimbostratus
Feb 27, 2015Hello all,
Sorry for the delay with my feedback and thank you everyone for help. I managed to get some help from highly skilled iRule engineer, and below I am placing the final version. The biggest advantage of the iRule is that adding more clients, doesn't require any code modification. All I have to do is to modify 2 data groups; one called Clients_IPs (which is going to be universal, and which will be created for each wide IP.
when DNS_REQUEST {
set mon "[class match -value [IP::remote_addr] equals Clients_IPs]"
set ip "[class match -value [DNS::question name] equals www.test.com_IP]"
if { ( $mon ne "" ) && ( $ip ne "" ) } {
if {[LB::status vs $mon up]} {
host [getfield $ip "," 1]
} else {
host [getfield $ip "," 2]
}
}
}Regards
Mariusz
- JRahm_128324Feb 27, 2015Historic F5 Accountnice! I try to keep logic in the iRule, data in data-groups personally, but during development for rapid prototyping I put the data in the iRule in if/else or switch conditions.For simple situations where the list won't grow beyond a few entries, if/else or switch is fine.
- Mariusz_BFeb 27, 2015
Nimbostratus
Yes, you're right. Probably www.test.com_IP is not necessary. To simplify I can hardcode the IPs. I have to create separate iRule for each Wide IP anyway. This is good if you expect your IP to be change in the future. In this case you don't have to interfere with the iRule code. Cheers
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
