Forum Discussion

RoutingLoop_179's avatar
Nov 15, 2012

Search a class datagroup for the value and find the name

Hi I've got created a string/value datagroup which maps domain to IP.

 

e.g

 

www.domain.com:=1.1.1.1

 

www.domain2.com:=2.2.2.2

 

 

so initially to find to corresponding IP of the domain i do a class match on the string name and return the value which is working as i want.

 

e.g

 

set ip [class match -value [DNS::question name] equals whitelist_ip]

 

 

However in a different irule for different traffic i want to use the same datagroup but essentially do the reverse, i want to use an IP to find the corresponding domain name in the datagroup. Bassically search the values of the datagroup and find the name it relates to it.

 

Is there an efficient/fast way to do this with a single datagroup or ifile, it could potentially hold 100/1000's of lines.

 

 

regards

 

Adrian

 

 

 

 

 

5 Replies

  • Hi Adrian,

     

     

    You could try iterating through the data group to search the values or retrieving it as a TCL list, but it would perform horribly compared with having a second data group where you're searching the key.

     

     

    Aaron
  • Thanks Aaron - so a second datagroup which is the reverse of the first would actually perform better? I'm trying to think of the ongoing maintenance of the DG as they will be added to over time, plus in my scenerio it is crucial the datagroups would need to stay in sync i.e DG1{domain1 = IP1;domain2=IP2}, DG2{IP1=domain1;IP2=domain2} so that there is always that map between the two. Having two files obviously increases the chance for error as values get added, but i'm also talking very high enterprise network so performance is crucial. hmmm i have some thinking.

     

     

    On a sort of related point would you know if there is a way to import and append existing Datagroups with multiple entries? I can't see away from the GUI apart from importing it at the initial creation and then adding/removing line by line. I'm looking into the API's, CLI and TMSH

     

     

    Thanks again
  • think i've managed to answer my own - question. How does the performance of a internal datagroup class compare to an external datagroup class?
  • You could write a script that creates the second data group after any changes have been made to the first data group. You'd probably want to run the script from cron or as an external monitor. You could check to see if the modify time of the first data group has changed since the last script runtime. Or you could modify whatever process you're using to set the first data group to also update the second one.

     

     

    The performance of an internal and external data group should be identical as they're both loaded into TMM memory.

     

     

    Aaron
  • Thanks again Aaron, yes as performance is more important to us, i've already found/thought of relatively easy ways to maintain the two files and import them [ actually through some of your previous replies to other posts :-) ]. Plus it's even better if you say the internal and external classes perform the same, as I could get our software teams to write a separate API which could automatically maintain and upload and load the files. thanks again - don't suppose you've got some thoughts on my new post regarding the node command ;-)