Forum Discussion
new to iRules
Hello, I am trying to create an iRule that uses a specific persistence profile if the incoming IP address is a member of a datagroup. I created the datagroup of type address and added my IPs. I'm trying to now create the iRule to use a hash persistence if the incoming IP address is a member of the data group and to use a source_addr persistence profile if not. Below is my iRule definition based on a datagroup of ABC:
when CLIENT_ACCEPTED { if { [matchclass [IP::remote_addr] equals $::ABC]} { persist hash } else { persist source_addr } }
When I try to save the iRule, I get the following error: 01070151:3: Rule [/ABC/ABC] error: /ABC/ABC:3: error: ["unexpected end of command;expected argument spec:ANY_CHARS"][persist hash]
what am I doing wrong? Thanks in advance
Your persist hash requires something to use as the hash.
https://devcentral.f5.com/wiki/iRules.persist.ashx
when CLIENT_ACCEPTED { if { [matchclass [IP::remote_addr] equals $::ABC]} { persist hash } else { persist source_addr } }
5 Replies
- Brad_Parker
Cirrus
Your persist hash requires something to use as the hash.
https://devcentral.f5.com/wiki/iRules.persist.ashx
when CLIENT_ACCEPTED { if { [matchclass [IP::remote_addr] equals $::ABC]} { persist hash } else { persist source_addr } }- Brad_Parker
Cirrus
Also, unless you are using BigIP v9 I suggest using class match instead of matchclass and calling your datagroup by name, i.i "/Common/ABC". Both are deprecated and in v11 calling at datagrou via $:: will actually throw TCL errors. https://devcentral.f5.com/wiki/iRules.class.ashx
- Brad_Parker_139
Nacreous
Your persist hash requires something to use as the hash.
https://devcentral.f5.com/wiki/iRules.persist.ashx
when CLIENT_ACCEPTED { if { [matchclass [IP::remote_addr] equals $::ABC]} { persist hash } else { persist source_addr } }- Brad_Parker_139
Nacreous
Also, unless you are using BigIP v9 I suggest using class match instead of matchclass and calling your datagroup by name, i.i "/Common/ABC". Both are deprecated and in v11 calling at datagrou via $:: will actually throw TCL errors. https://clouddocs.f5.com/api/irules/class.html
- Matthew_WV_1894
Nimbostratus
Thank you, much appreciated. That clears up why I was getting TCL errors as soon as I tested this rule:) Working now, thanks for the help.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com