# iRule Source IP to prioritized list of pool members

**URL:** <https://community.f5.com/t/irule-source-ip-to-prioritized-list-of-pool-members/53104>\
**Category:** Technical Forums\
**Tags:** irules, devops, ltm\
**Created:** [February 4, 2021, 10:52pm UTC](https://community.f5.com/t/irule-source-ip-to-prioritized-list-of-pool-members/53104 "2021-02-04T22:52:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmp19](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@cmp19](https://community.f5.com/u/cmp19)\
**Post date:** [February 4, 2021, 10:52pm UTC](https://community.f5.com/t/irule-source-ip-to-prioritized-list-of-pool-members/53104/1 "2021-02-04T22:52:55Z")

</div>

Hi!

Trying to create an iRule that matches a clients source IP and sends it to a specific pool member. If the pool member is down or offline, send it to a different member in the same pool. So far the source client is sticking to the first pool member in my statement, but when I turn that pool member off, connections are failing to pool member #2. What have I missed? Thanks for checking it out!

\*\*Note %12 is my route domain this traffic lives in

```tcl
when CLIENT_ACCEPTED {
 if { [IP::addr [IP::client_addr] equals a.a.a.a%12] } {
   pool test_pool member 2.2.2.2%12 8443
 } else {
   pool test_pool member 3.3.3.3%12 8443
 }
}

```

---

<div class="post-metadata">

**Author:** ![Amine\_Kadimi](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Amine\_Kadimi](https://community.f5.com/u/Amine_Kadimi)\
**Post date:** [February 4, 2021, 11:38pm UTC](https://community.f5.com/t/irule-source-ip-to-prioritized-list-of-pool-members/53104/2 "2021-02-04T23:38:09Z")

</div>

Basically, you are forcing the load balancing to member 1 whatever its status is. You need to either check its [status](https://clouddocs.f5.com/api/irules/LB__status.html) before selecting it, or to use LB\_FAILED event after selection to [reselect](https://clouddocs.f5.com/api/irules/LB__reselect.html) another pool member.

```tcl
when CLIENT_ACCEPTED {
     if { [IP::addr [IP::client_addr] equals a.a.a.a%12] } {
      if { [LB::status pool test_pool member 2.2.2.2%12 8443] eq "up" } {
       pool test_pool member 2.2.2.2%12 8443
      } else {
       pool test_pool member 3.3.3.3%12 8443
      }
     }
    }

```

---

<div class="post-metadata">

**Author:** ![cmp19](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@cmp19](https://community.f5.com/u/cmp19)\
**Post date:** [February 4, 2021, 11:57pm UTC](https://community.f5.com/t/irule-source-ip-to-prioritized-list-of-pool-members/53104/3 "2021-02-04T23:57:40Z")

</div>

This is exactly what I was missing. Thanks for such a quick response Amine!!
