# IRULE - IP::client\_addr

**URL:** <https://community.f5.com/t/irule-ip-client-addr/48996>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [December 22, 2011, 1:07pm UTC](https://community.f5.com/t/irule-ip-client-addr/48996 "2011-12-22T13:07:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LillyM\_9417](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@LillyM\_9417](https://community.f5.com/u/LillyM_9417)\
**Post date:** [December 22, 2011, 1:07pm UTC](https://community.f5.com/t/irule-ip-client-addr/48996/1 "2011-12-22T13:07:06Z")

</div>

Hello,

I want to ask a question about “IP::client\_addr”. I write the following irule:

When client has the X.X.X.3 ip address, it goes to the first “if” thats okey and I see from the ltm log ( I opened a debug..) , but the connection is not forwarded to the Pool x it is forwarded to the default Pool, I also see from the log file that the same connection is also forwarded to the default pool. How can it be possible? What is wrong in this irule?

if { [IP::addr [IP::client\_addr] equals x.x.x.0/24]}{

pool X

}

if { [IP::addr [IP::client\_addr] equals y.y.y.0/24]}{

pool Y

}

else {

default pool

}

---

<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:** [December 22, 2011, 1:11pm UTC](https://community.f5.com/t/irule-ip-client-addr/48996/2 "2011-12-22T13:11:33Z")

</div>

have you forgotten else between the first and second if statement?

e.g.

```tcl
if {[IP::addr [IP::client_addr] equals x.x.x.0/24]} {
   pool X
} elseif {[IP::addr [IP::client_addr] equals y.y.y.0/24]} {
   pool Y
} else {
   pool default
}

```

---

<div class="post-metadata">

**Author:** ![LillyM\_9417](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@LillyM\_9417](https://community.f5.com/u/LillyM_9417)\
**Post date:** [December 22, 2011, 1:49pm UTC](https://community.f5.com/t/irule-ip-client-addr/48996/3 "2011-12-22T13:49:33Z")

</div>

Thanks for your advice, I will try it now 🙂

---

<div class="post-metadata">

**Author:** ![LillyM\_9417](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@LillyM\_9417](https://community.f5.com/u/LillyM_9417)\
**Post date:** [December 22, 2011, 2:15pm UTC](https://community.f5.com/t/irule-ip-client-addr/48996/4 "2011-12-22T14:15:43Z")

</div>

it works, you are great!

---

<div class="post-metadata">

**Author:** ![Colin\_Walker\_12](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Colin\_Walker\_12](https://community.f5.com/u/Colin_Walker_12)\
**Post date:** [December 27, 2011, 9:41pm UTC](https://community.f5.com/t/irule-ip-client-addr/48996/5 "2011-12-27T21:41:46Z")

</div>

This is an excellent example of the way that the pool command actually works in an iRule. It’s effectively updating a pointer that is used to route traffic. I think this one deserves a Tech Tip, adding it to my list for the iRules Concepts series to do some more digging on.

Colin
