# Irule to select a pool member that's not the same as the requesting client's ip

**URL:** <https://community.f5.com/t/irule-to-select-a-pool-member-thats-not-the-same-as-the-requesting-clients-ip/20388>\
**Category:** Technical Forums\
**Tags:** management, irules, devops, ltm, application-delivery, sap\
**Created:** [June 5, 2015, 3:31pm UTC](https://community.f5.com/t/irule-to-select-a-pool-member-thats-not-the-same-as-the-requesting-clients-ip/20388 "2015-06-05T15:31:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisS\_DevOps\_2](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@ChrisS\_DevOps\_2](https://community.f5.com/u/ChrisS_DevOps_2)\
**Post date:** [June 5, 2015, 3:31pm UTC](https://community.f5.com/t/irule-to-select-a-pool-member-thats-not-the-same-as-the-requesting-clients-ip/20388/1 "2015-06-05T15:31:45Z")

</div>

We have pool members that will make http requests to vips with pools the requester could itself be a member of

I need a quick irule to make sure that if a server’s http request cannot be routed back onto itself.

---

<div class="post-metadata">

**Author:** ![JRahm](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/jrahm/32/3327_2.png) [@JRahm](https://community.f5.com/u/JRahm)\
**Post date:** [June 5, 2015, 4:55pm UTC](https://community.f5.com/t/irule-to-select-a-pool-member-thats-not-the-same-as-the-requesting-clients-ip/20388/2 "2015-06-05T16:55:25Z")

</div>

how will you tie the sessions together? Is there something in the original request that would be evident in the request initiated by the server?

---

<div class="post-metadata">

**Author:** ![JRahm](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/jrahm/32/3327_2.png) [@JRahm](https://community.f5.com/u/JRahm)\
**Post date:** [June 5, 2015, 5:00pm UTC](https://community.f5.com/t/irule-to-select-a-pool-member-thats-not-the-same-as-the-requesting-clients-ip/20388/3 "2015-06-05T17:00:31Z")

</div>

if you just want a client can’t be server rule, that shouldn’t be too challenging:

```tcl
when LB_SELECTED {
  if { [IP::client_addr] == [IP::server_addr] }
    LB::detach
    LB::reselect
  }
}

```

You might want to add an escape after X number of attempts to prevent a loop in the event the same member keeps getting selected.

---

<div class="post-metadata">

**Author:** ![nitass](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/nitass/32/2270_2.png) [@nitass](https://community.f5.com/u/nitass)\
**Post date:** [June 11, 2015, 11:43am UTC](https://community.f5.com/t/irule-to-select-a-pool-member-thats-not-the-same-as-the-requesting-clients-ip/20388/4 "2015-06-11T11:43:51Z")

</div>

this is mine. i disabled cmp because i wanted to test with one tmm.

```tcl
configuration

[root@ve11c:Active:In Sync] config tmsh list ltm virtual bar
ltm virtual bar {
    cmp-enabled no
    destination 200.200.200.10:80
    mask 255.255.255.255
    pool foo
    profiles {
        fastL4 { }
    }
    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
        }
        200.200.200.102:80 {
            address 200.200.200.102
        }
        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 CLIENT_ACCEPTED {
  log local0. "client: [IP::client_addr]:[TCP::client_port] server:"
}
when LB_SELECTED {
  log local0. "client: [IP::client_addr]:[TCP::client_port] server: [LB::server addr]:[LB::server port]"
  if { [IP::client_addr] == [LB::server addr] } {
    log local0. "client: [IP::client_addr]:[TCP::client_port] LB::reselect"
    LB::reselect
  }
}
when SERVER_CONNECTED {
  log local0. "client: [IP::client_addr]:[TCP::client_port] server: [LB::server addr]:[LB::server port]"
}
}

 /var/log/ltm

[root@ve11c:Active:In Sync] config tail -f /var/log/ltm
Jun 11 19:41:37 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44464 server:
Jun 11 19:41:37 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44464 server: 200.200.200.102:80
Jun 11 19:41:37 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44464 server: 200.200.200.102:80

Jun 11 19:41:43 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44465 server:
Jun 11 19:41:43 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44465 server: 200.200.200.101:80
Jun 11 19:41:43 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44465 LB::reselect
Jun 11 19:41:43 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44465 server: 200.200.200.111:80
Jun 11 19:41:43 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44465 server: 200.200.200.111:80

Jun 11 19:41:49 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44466 server:
Jun 11 19:41:49 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44466 server: 200.200.200.102:80
Jun 11 19:41:49 ve11c info tmm[10748]: Rule /Common/qux : client: 200.200.200.101:44466 server: 200.200.200.102:80

```
