# pool selection iRule not working

**URL:** <https://community.f5.com/t/pool-selection-irule-not-working/10871>\
**Category:** Technical Forums\
**Tags:** irules, design, devops, ltm, application-delivery\
**Created:** [June 19, 2014, 11:36am UTC](https://community.f5.com/t/pool-selection-irule-not-working/10871 "2014-06-19T11:36:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_Vitiritt](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@Nathan\_Vitiritt](https://community.f5.com/u/Nathan_Vitiritt)\
**Post date:** [June 19, 2014, 11:36am UTC](https://community.f5.com/t/pool-selection-irule-not-working/10871/1 "2014-06-19T11:36:35Z")

</div>

I need help understanding and resolving why my iRule that uses a data group is only working for 2 out of the three addresses in the group. My current configuration is a standard VIP listening on port 80 using a HTTP and One Connect profile along with SNAT. This VIP has three iRules assigned to it that do various redirects with the one in question using a data group to identify 3 IP addresses that connect to us and redirect them to a different pool of servers. The iRule looks like this:

when CLIENT\_ACCEPTED { If remote IP address matches the datagroup then select new pool if { [class match [IP::remote\_addr] equals [data.group.com](http://data.group.com)] } { pool new server.pool.com-pool If remote IP address doesn’t match datagroup default to VIP pool } else { pool existing.server.pool } }

This is working for two of the 3 IP addresses in the data group. The one is still being directed to the existing server pool. I have double and triple checked everything and do not understand this behavior. Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Kevin\_Davies](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_davies/32/1696_2.png) [@Kevin\_Davies](https://community.f5.com/u/Kevin_Davies)\
**Post date:** [June 19, 2014, 11:54am UTC](https://community.f5.com/t/pool-selection-irule-not-working/10871/2 "2014-06-19T11:54:15Z")

</div>

```tcl
when CLIENT_ACCEPTED { 
   If remote IP address matches the datagroup then select new pool 
  if { [class match [IP::remote_addr] equals data.group.com] } { 
    pool server.pool.com-pool 
     If remote IP address doesn't match datagroup default to VIP pool 
  } else { 
    pool existing.server.pool 
  }
}

```

You had a typo… pool new is not a valid command.

---

<div class="post-metadata">

**Author:** ![Kevin\_Davies](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_davies/32/1696_2.png) [@Kevin\_Davies](https://community.f5.com/u/Kevin_Davies)\
**Post date:** [June 19, 2014, 11:55am UTC](https://community.f5.com/t/pool-selection-irule-not-working/10871/3 "2014-06-19T11:55:13Z")

</div>

Can you paste the contents of the datagroup with the three IP addresses?

---

<div class="post-metadata">

**Author:** ![Nathan\_Vitiritt](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@Nathan\_Vitiritt](https://community.f5.com/u/Nathan_Vitiritt)\
**Post date:** [June 19, 2014, 11:57am UTC](https://community.f5.com/t/pool-selection-irule-not-working/10871/4 "2014-06-19T11:57:58Z")

</div>

The typo only existed in the post and not on the production iRule. I have fixed it below to reflect properly. I wasn’t trying to use new as a command.

when CLIENT\_ACCEPTED { If remote IP address matches the datagroup then select new pool if { [class match [IP::remote\_addr] equals [data.group.com](http://data.group.com)] } { pool newserver.pool.com-pool If remote IP address doesn’t match datagroup default to VIP pool } else { pool existing.server.pool } }

---

<div class="post-metadata">

**Author:** ![Kevin\_Davies](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_davies/32/1696_2.png) [@Kevin\_Davies](https://community.f5.com/u/Kevin_Davies)\
**Post date:** [June 19, 2014, 12:04pm UTC](https://community.f5.com/t/pool-selection-irule-not-working/10871/5 "2014-06-19T12:04:07Z")

</div>

Ok then your iRule looks good. You need to turn on logging to see what IP::remote\_addr is actually giving you and please post an example of one line in your datagroup.

```tcl
when CLIENT_ACCEPTED { 
   If remote IP address matches the datagroup then select new pool 
  log local0. "Remote address is [IP::remote_addr]"
  if { [class match [IP::remote_addr] equals data.group.com] } { 
    pool newserver.pool.com-pool 
     If remote IP address doesn't match datagroup default to VIP pool 
  } else { 
    pool existing.server.pool 
  }
}

```

---

<div class="post-metadata">

**Author:** ![Nathan\_Vitiritt](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@Nathan\_Vitiritt](https://community.f5.com/u/Nathan_Vitiritt)\
**Post date:** [June 19, 2014, 12:22pm UTC](https://community.f5.com/t/pool-selection-irule-not-working/10871/6 "2014-06-19T12:22:48Z")

</div>

Here is the data-group:

ltm data-group internal [custom.datagroup.com](http://custom.datagroup.com) { records { 1.1.1.1/32 { } 2.2.2.2/32 { } 3.3.3.3/32 { } } type ip }

All but 3.3.3.3 are being redirected to the newserver.pool.com-pool.

I also enabled logging and so far I haven’t seen the 3.3.3.3 address in the logs. I will give it more time to show up.

---

<div class="post-metadata">

**Author:** ![Kevin\_Davies](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_davies/32/1696_2.png) [@Kevin\_Davies](https://community.f5.com/u/Kevin_Davies)\
**Post date:** [June 19, 2014, 12:45pm UTC](https://community.f5.com/t/pool-selection-irule-not-working/10871/7 "2014-06-19T12:45:41Z")

</div>

Everything you have done is spot on so there is nothing wrong with your iRule. My only suggestion is watch IP addresses coming in. Quite often expectations don’t meet reality about incoming data. Logging is your source of truth.

---

<div class="post-metadata">

**Author:** ![THi](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@THi](https://community.f5.com/u/THi)\
**Post date:** [June 19, 2014, 1:08pm UTC](https://community.f5.com/t/pool-selection-irule-not-working/10871/8 "2014-06-19T13:08:31Z")

</div>

You mentioned 3 iRules. What are the other two doing? Could there be some conflicting logic? This iRule is fired early in the http connection (CLIENT\_ACCEPTED event). As there is no escape (return) in this iRule, the connection flow continues and next event is HTTP\_REQUEST and so on. So the other iRules may/will fire, too.
