Forum Discussion
irule
Hello, I have a virtual server with default pool Pool1 configured, containing 2 servers (10.10.10.2/3). Now I'm trying to achieve that if request will come from client with IP 192.168.1.2 it will be forwarded to 10.10.10.2 and if from client 192.168.1.3 it will be forwarded to 10.10.10.3. iRule should looks like this:
when HTTP_REQUEST {
if { [IP::addr [IP::client_addr] equals 192.168.1.2] } {
pool Pool1 member 10.10.10.2 80
}
else if { [IP::addr [IP::client_addr] equals 192.168.1.3] } {
pool Pool1 member 10.10.10.3 80
}
}
My question is what will happen if server 10.10.10.2 will go down. In that case I'd like to forward all requests to second server which is up. But I have a feeling that with this iRule client with ip 192.168.1.2 will be forwarded anyway to server1 which is down. Am I right ? And if yes how to avoid this situation ?
8 Replies
- nitass_89166
Noctilucent
In that case I'd like to forward all requests to second server which is up. But I have a feeling that with this iRule client with ip 192.168.1.2 will be forwarded anyway to server1 which is down. Am I right ? And if yes how to avoid this situation ?
you may check pool member/node status before forwarding traffic.
LB::status
https://devcentral.f5.com/wiki/iRules.LB__status.ashx
- nitass_89166
Noctilucent
noted, Scott. thanks!
- nitass
Employee
In that case I'd like to forward all requests to second server which is up. But I have a feeling that with this iRule client with ip 192.168.1.2 will be forwarded anyway to server1 which is down. Am I right ? And if yes how to avoid this situation ?
you may check pool member/node status before forwarding traffic.
LB::status
https://devcentral.f5.com/wiki/iRules.LB__status.ashx
- nitass
Employee
noted, Scott. thanks!
- duBeN_25069
Nimbostratus
great, thanks so it will looks like this:
when HTTP_REQUEST { if { [LB::status pool $poolname member $ip $port] eq "up" && [LB::status pool $poolname member $ip2 $port] eq "up" } { if { [IP::addr [IP::client_addr] equals $client] } { pool $poolname member $ip $port } elseif { [IP::addr [IP::client_addr] equals $client2] } { pool $poolname member $ip2 $port } } } - nitass
Employee
you can use active_members to check number of active pool members.
active_members
https://devcentral.f5.com/wiki/iRules.active_members.ashx - Kevin_Stewart
Employee
Or perhaps something like this:
when HTTP_REQUEST { if { ( [IP::addr [IP::client_addr] equals 192.168.1.2] ) and [LB::status pool Pool1 member 10.10.10.2 80] eq "up" ) } { pool Pool1 member 10.10.10.2 80 } elseif { ( [IP::addr [IP::client_addr] equals 192.168.1.3] ) and [LB::status pool Pool1 member 10.10.10.3 80] eq "up" ) } { pool Pool1 member 10.10.10.3 80 } else { not technically necessary if the pool is assigned to the VIP pool pool Pool1 } }This basically says, if the client source is this, and the specific pool member is up, then go ahead and send it. Otherwise send the request to whoever is available in the (default) pool.
- duBeN_25069
Nimbostratus
uf, lot of options - I like it :)
Thank you guys
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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