# Class Match iRule problem

**URL:** <https://community.f5.com/t/class-match-irule-problem/558>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [June 14, 2012, 1:25am UTC](https://community.f5.com/t/class-match-irule-problem/558 "2012-06-14T01:25:49Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![AaronMLong\_1021](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@AaronMLong\_1021](https://community.f5.com/u/AaronMLong_1021)\
**Post date:** [June 14, 2012, 1:25am UTC](https://community.f5.com/t/class-match-irule-problem/558/1 "2012-06-14T01:25:49Z")

</div>

So I’m writing a simple dust page rule, which I want to make a few exceptions based on source address. I used to have a if/then/else nightmare in 9.4.4, so I’m not sorry to revisit the issue, but the class match syntax is still evading me, I think. Either that or there’s some other screwup in here I’m missing:

```tcl
when HTTP_REQUEST {
   if { [class match [IP::client_addr] equals 
"AWS_EC2"] } {
       Allow Amazon EC2 nodes past DUST Page
   } elseif 
{ [class match [IP::client_addr] equals "Testers"] } {
       Allow Testers 
past DUST Page
   } else {
      HTTP::redirect 
"URL"
   }
}

```

My data groups are entered using the Data Group Editor in the F5 iRule Editor, under Addresses. When I access from an IP listed in my class match clauses, I still get redirected to URL. What am I screwing up?

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [June 14, 2012, 1:13pm UTC](https://community.f5.com/t/class-match-irule-problem/558/2 "2012-06-14T13:13:39Z")

</div>

Hi Aaron,

Can you add some debug logging, retest and check /var/log/ltm for the log output for a failure?

```tcl
when HTTP_REQUEST {
   log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] to [virtual name] [HTTP::host][HTTP::uri]"
   if { [class match [IP::client_addr] equals AWS_EC2] } {
       Allow Amazon EC2 nodes past DUST Page
      log local0. "[IP::client_addr]:[TCP::client_port]: Matched AWS_EC2"
   } elseif { [class match [IP::client_addr] equals Testers] } {
       Allow Testers past DUST Page
      log local0. "[IP::client_addr]:[TCP::client_port]: Matched Testers"
   } else {
      HTTP::redirect "URL"
      log local0. "[IP::client_addr]:[TCP::client_port]: No match in AWS_EC2: [class get AWS_EC2] or Testers: [class get Testers]"
   }
}

```

Aaron

---

<div class="post-metadata">

**Author:** ![AaronMLong\_1021](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@AaronMLong\_1021](https://community.f5.com/u/AaronMLong_1021)\
**Post date:** [June 14, 2012, 8:28pm UTC](https://community.f5.com/t/class-match-irule-problem/558/3 "2012-06-14T20:28:34Z")

</div>

Okay, I added the log data, and now I’m really baffled:

Jun 14 13:26:52 local/tmm2 info tmm2[4997]: Rule dust-appctr-planned-prod : 209.119.85.5%1:48622: No match in AWS\_EC2: {2620:0:c10:f501:0:1:ae81:0/32 {}} {2620:0:c10:f501:0:1:b848:0/39 {}} {2620:0:c10:f501:0:1:ccec:8000/33 {}} {2620:0:c10:f501:0:1:1714:0/30 {}} {2620:0:c10:f501:0:1:3210:0/30 {}} {2620:0:c10:f501:0:1:43ca:0/34 {}} {2620:0:c10:f501:0:1:482c:2000/35 {}} {2620:0:c10:f501:0:1:4b65:8000/33 {}} or Testers: 2620:0:c10:f501:0:1:d177:5505/48 {}

What the heck is going on with that data group? I added networks using the iRule editor.

---

<div class="post-metadata">

**Author:** ![AaronMLong\_1021](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@AaronMLong\_1021](https://community.f5.com/u/AaronMLong_1021)\
**Post date:** [June 14, 2012, 8:28pm UTC](https://community.f5.com/t/class-match-irule-problem/558/4 "2012-06-14T20:28:57Z")

</div>

Okay, I added the log data, and now I’m really baffled:

Jun 14 13:26:52 local/tmm2 info tmm2[4997]: Rule dust-appctr-planned-prod : 209.119.85.5%1:48622: No match in AWS\_EC2: {2620:0:c10:f501:0:1:ae81:0/32 {}} {2620:0:c10:f501:0:1:b848:0/39 {}} {2620:0:c10:f501:0:1:ccec:8000/33 {}} {2620:0:c10:f501:0:1:1714:0/30 {}} {2620:0:c10:f501:0:1:3210:0/30 {}} {2620:0:c10:f501:0:1:43ca:0/34 {}} {2620:0:c10:f501:0:1:482c:2000/35 {}} {2620:0:c10:f501:0:1:4b65:8000/33 {}} or Testers: 2620:0:c10:f501:0:1:d177:5505/48 {}

What the heck is going on with that data group? I added networks using the iRule editor.

---

<div class="post-metadata">

**Author:** ![MiLK\_MaN](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@MiLK\_MaN](https://community.f5.com/u/MiLK_MaN)\
**Post date:** [June 14, 2012, 11:41pm UTC](https://community.f5.com/t/class-match-irule-problem/558/5 "2012-06-14T23:41:33Z")

</div>

Can you paste the contents of your data-group?

As you are using route domains, you are going to need to list the IP in the data-group as x.x.x.x%. So in your log output from above, make sure the data-group has an entry with:

209.119.85.5%1

---

<div class="post-metadata">

**Author:** ![AaronMLong\_1021](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@AaronMLong\_1021](https://community.f5.com/u/AaronMLong_1021)\
**Post date:** [June 14, 2012, 11:49pm UTC](https://community.f5.com/t/class-match-irule-problem/558/6 "2012-06-14T23:49:54Z")

</div>

I entered the networks via the Data Group Editor in the F5 iRule editor. Right now my testers data group has:

209.119.85.5

in it and nothing else. It was entered as 209.119.85.5/255.255.255.255 with no value field attached.

---

<div class="post-metadata">

**Author:** ![MiLK\_MaN](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@MiLK\_MaN](https://community.f5.com/u/MiLK_MaN)\
**Post date:** [June 15, 2012, 12:33am UTC](https://community.f5.com/t/class-match-irule-problem/558/7 "2012-06-15T00:33:03Z")

</div>

Try changing the entry to be 209.119.85.5%1 in the data-group.

---

<div class="post-metadata">

**Author:** ![AaronMLong\_1021](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@AaronMLong\_1021](https://community.f5.com/u/AaronMLong_1021)\
**Post date:** [June 15, 2012, 1:02am UTC](https://community.f5.com/t/class-match-irule-problem/558/8 "2012-06-15T01:02:38Z")

</div>

Done. No change in the output:

Jun 14 18:01:28 local/tmm2 info tmm2[4997]: Rule dust-appctr-planned-prod : 209.119.85.5%1:34494: No match in AWS\_EC2: {2620:0:c10:f501:0:1:ae81:0/32 {}} {2620:0:c10:f501:0:1:b848:0/39 {}} {2620:0:c10:f501:0:1:ccec:8000/33 {}} {2620:0:c10:f501:0:1:1714:0/30 {}} {2620:0:c10:f501:0:1:3210:0/30 {}} {2620:0:c10:f501:0:1:43ca:0/34 {}} {2620:0:c10:f501:0:1:482c:2000/35 {}} {2620:0:c10:f501:0:1:4b65:8000/33 {}} or Testers: 2620:0:c10:f501:0:1:d177:5505/48 {}

---

<div class="post-metadata">

**Author:** ![AaronMLong\_1021](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@AaronMLong\_1021](https://community.f5.com/u/AaronMLong_1021)\
**Post date:** [June 18, 2012, 6:13pm UTC](https://community.f5.com/t/class-match-irule-problem/558/9 "2012-06-18T18:13:28Z")

</div>

Any more help incoming on this one? It’s not as if I’m trying to do something particularly bizarre and difficult.

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [June 18, 2012, 8:09pm UTC](https://community.f5.com/t/class-match-irule-problem/558/10 "2012-06-18T20:09:56Z")

</div>

Data groups and the associated lookup commands (matchclass, class, findclass, etc) do not support route domains yet. See this thread for details and possible workarounds:

> **[DevCentral](https://community.f5.com/)**
>
> DevCentral is an online technical community where engineers and practitioners collaborate, share knowledge, and solve problems related to F5 technologies and industry trends.

Aaron

---

<div class="post-metadata">

**Author:** ![AaronMLong\_1021](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@AaronMLong\_1021](https://community.f5.com/u/AaronMLong_1021)\
**Post date:** [June 18, 2012, 9:25pm UTC](https://community.f5.com/t/class-match-irule-problem/558/11 "2012-06-18T21:25:32Z")

</div>

Ah, thank you! Moving my class to the common partition seems to have done the trick. Strange behaviour.

---

<div class="post-metadata">

**Author:** ![moriarti\_26889](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@moriarti\_26889](https://community.f5.com/u/moriarti_26889)\
**Post date:** [June 27, 2012, 12:38pm UTC](https://community.f5.com/t/class-match-irule-problem/558/12 "2012-06-27T12:38:44Z")

</div>

HI, we are having the same issue. I will take this workaround and move the datagroup to the common partition. Thank you very much for this temporary solution, I hope F5 guys give us a solution soon.

---

<div class="post-metadata">

**Author:** ![moriarti\_26889](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@moriarti\_26889](https://community.f5.com/u/moriarti_26889)\
**Post date:** [July 2, 2012, 10:00am UTC](https://community.f5.com/t/class-match-irule-problem/558/13 "2012-07-02T10:00:12Z")

</div>

Well, finally there is not a real workaround here, moving the datagroup to the common partition does not make any difference. sol12301 says it very clearly, if you are not working with the default routing domain, the class command will not work
