# Retrieve the highest number of requests

**URL:** <https://community.a10networks.com/t/retrieve-the-highest-number-of-requests/730>\
**Category:** aFleX\
**Tags:** aflex\
**Created:** [June 22, 2022, 8:32am UTC](https://community.a10networks.com/t/retrieve-the-highest-number-of-requests/730 "2022-06-22T08:32:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![waiwaileung](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@waiwaileung](https://community.a10networks.com/u/waiwaileung)\
**Post date:** [June 22, 2022, 8:32am UTC](https://community.a10networks.com/t/retrieve-the-highest-number-of-requests/730/1 "2022-06-22T08:32:01Z")

</div>

If I want to add one more rule which is to black list the highest number of DNS query when the total number of DNS queries exceed the threshold value (i.e. $totalcount). How can I retrieve the IP address which has the highest number of DNS query?  
set totalcount [table incr tmp\_table [IP::client\_addr]]  
if { $totalcount \> $::TOTALMAXQUERY } {  
//Blacklist the IP which has the highest number of DNS Query  
}

when DNS\_REQUEST {  
if { [table lookup “blacklist” [IP::client\_addr]] != “” } {  
log “The Blacklist for [IP::client\_addr] expires in [table lifetime “blacklist” -  
remaining [IP::client\_addr]] seconds”  
drop  
return  
}  
if { [table lookup tmp\_table [IP::client\_addr]] == “” } {  
table set tmp\_table [IP::client\_addr] 1 indef 1  
log “The table entry created for [IP::client\_addr]”  
return  
}  
set count [table incr tmp\_table [IP::client\_addr]]  
log “The DNS Query $count of $::MAXQUERY for [IP::client\_addr]”  
if { $count \> $::MAXQUERY } {  
table add “blacklist” $key “blocked” indef $::HOLDTIME  
log “The Blacklist entry created for [IP::client\_addr]”  
table delete tmp\_table $key  
drop  
return  
}  
}
