Datagroup into variable

Hi I am making an Irule and I need to set the value of a datagroup into a variable. Something like this

set url [RESOLV::lookup @8.8.8.8 domains]

I want that the varaible url gets the value of the dns result the datagroup domains.

Please help

I think this question answers what you need to do:

he uses a foreach loop with the datagroup as the variables then you put your command set url, and whatever else after that.

In this example, you have a datagroup called ‘domains’ and a record, ‘mydomain.com’ which has a value of ‘10.1.1.1’

ltm data-group internal domains {
        records {
            mydomain.com {
                data 10.1.1.1
            }
        }
        type string
    }

In an iRule, you can use the -value switch to return the value in a datagroup, rather than a Boolean match when using the class command

The following code will set a variable ‘url’ to ‘10.1.1.1’

set url [class match -value "mydomain.com" equals "domains"]