Forum Discussion
Dave_Mehlberg
Cirrus
Feb 13, 2025Can i use shared objects as I do data groups, in iRules?
I need to write a few iRules for policy NATing and using Shared Objects, would make the task (and iRules) cleaner and less complex. For instance: when CLIENT_ACCEPTED { if {[matchclass[IP::r...
- Feb 13, 2025
I don't believe it is possible to reference Shared Objects within an iRule; you can only reference internal or external data groups. I agree, it would be useful to have it as a feature though.
Feb 14, 2025
You should not be Using matchclass (this keyword is deprecated/obsolete) instead use class match:
-
- The matchclass command is not valid in this context, it was used before v10.
- The correct command to use is class match, which is specifically designed for matching entries in data groups or shared objects.
The correct command to use is class match, which is specifically designed for matching entries in data groups or shared objects.- when CLIENT_ACCEPTED {
if { [class match [IP::remote_addr] equals international-sites_netgrp] } {
pool infoblox-report
# log local0
}
} - if { [class match [IP::remote_addr] equals international-sites_netgrp] }:
- class match: This command checks if the client's IP address ([IP::remote_addr]) matches any entry in the specified data group or shared object.
- [IP::remote_addr]: This command retrieves the IP address of the client.
- equals international-sites_netgrp: This specifies the name of the shared object (address list) that contains the IP addresses or subnets to match against. In this case, international-sites_netgrp is a shared address list that includes other address lists or IP ranges.
Incorrect Syntax:- Using incorrect syntax or commands that are not supported by iRules will result in errors and the iRule will not function as intended.
For example, using class match [IP::remote_addr] without proper spacing or brackets will cause syntax errors.
Not Using Shared Objects:- If you do not use shared objects or data groups, you would need to hard-code the IP addresses or subnets directly in the iRule, making it less flexible and harder to maintain. Shared objects allow you to manage and update the lists separately from the iRule, simplifying maintenance and updates.
- Using incorrect syntax or commands that are not supported by iRules will result in errors and the iRule will not function as intended.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects