Forum Discussion
Select member from within two pools via 4th octet value in URI
The following iRule works well, but I'm in need of some expert help altering this to accept a number equal to the 4th octet of the member IP, looking at more than one pool.
https://devcentral.f5.com/wiki/iRules.Select_pool_member_based_on_HTTP_query_string_parameter.ashx
I'd like to put this one iRule on two VIPs (so it's more generic) and be able to select a member from 2 pools (the default of each VIP) from either VIP. So, pass in member=23 and look at 2 pools at the same time to find 192.168.1.23
This is to facilitate a test request for application support to a server in either the live pool (using the live VIP) or the 'dark' pool (but via the same live VIP). the LTM VIPs alternate based on GTM setting. Both VIPs/Pools are on the same LTM.
I'm ok with coding the two pool names, so merge the members from both pools to find the matching member/IP.
Any help would be appreciated!
5 Replies
- Brad_Parker
Cirrus
would give you the 4th octet of a pool members IP. Not exactly sure what you are wanting to change in that iRule, but this snippet should get you started.[getfield [LB::server addr] "." 4] - Jason_Hook_4092
Nimbostratus
I'm wondering how to combine two pools worth of member lists (or look in each pool separately) to find the matching member IP (in the noted iRule, it does a lIndex to pick the member from a sorted list, not real sure how to best alter that part to search the list for content matching on the 4th octet)
- Brad_Parker
Cirrus
why are you searching for a specific pool member? Why not just use the node command if you know the specific node you are trying to send traffic to? Big picture, what are you trying to accomplish? - Jason_Hook_4092
Nimbostratus
call the website with a URI param to connect to a specific server in one of the two pools and set a session cookie to persist for the session...so support can troubleshoot a single server in either the live pool or 'dark' pool. I suppose putting the entire IP in the URI as the param would be ok, figured just the 4th octet would be easier to type in. This app is also mobile enhanced so less typing would be desirable.
- nitass
Employee
is it something like this?
configuration [root@ve11c:Active:In Sync] config tmsh list ltm virtual bar ltm virtual bar { destination 172.28.24.10:80 ip-protocol tcp mask 255.255.255.255 pool foo profiles { http { } tcp { } } rules { qux } source 0.0.0.0/0 source-address-translation { type automap } vs-index 9 } [root@ve11c:Active:In Sync] config tmsh list ltm pool foo ltm pool foo { members { 200.200.200.101:80 { address 200.200.200.101 } } } [root@ve11c:Active:In Sync] config tmsh list ltm pool foobar ltm pool foobar { members { 200.200.200.111:80 { address 200.200.200.111 } } } [root@ve11c:Active:In Sync] config tmsh list ltm rule qux ltm rule qux { when RULE_INIT { List of pool name set static::poollist { foo foobar } Parameter name set static::uriparam "member" } when HTTP_REQUEST { set param [URI::query "?[HTTP::query]" $static::uriparam] if { $param ne "" } { foreach name $static::poollist { foreach mbr [active_members -list $name] { if { [lindex $mbr 0] ends_with $param } { log local0. "Param=$param Pool=$name Pool member=$mbr" pool $name members [lindex $mbr 0] [lindex $mbr 1] return } } } } else { No parameter } } } /var/log/ltm [root@ve11c:Active:In Sync] config tail -f /var/log/ltm Mar 10 22:21:14 ve11c info tmm[15262]: Rule /Common/qux : Param=111 Pool=foobar Pool member=200.200.200.111 80 Mar 10 22:21:24 ve11c info tmm[15262]: Rule /Common/qux : Param=101 Pool=foo Pool member=200.200.200.101 80
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