Control recursive DNS queries
Hi all,
I'm wondering if/how in aFlex I might be able to allow or deny recursive DNS queries based off a source IP list. For example, if a remote IP not on the list has the recursive bit set in the query, the A10 will block the query outright instead of forwarding it to the DNS server.
I'm wondering if/how in aFlex I might be able to allow or deny recursive DNS queries based off a source IP list. For example, if a remote IP not on the list has the recursive bit set in the query, the A10 will block the query outright instead of forwarding it to the DNS server.
Tagged:
0
Comments
Genard
You will need create a class-list (in this example the class list name is HOST_LIST)
You will need change the comments to do what you want, if you want to drop the connection you need change the comment by the command 'drop'.
aFlex Code:
when RULE_INIT {
set ::HOSTLIST HOST_LIST ;# Class List used for hosts and configured in partition
}
when CLIENT_ACCEPTED {
set ::IPADDR [IP::client_addr] ;# Ip address of client
}
when DNS_REQUEST {
if { [DNS::header rd] == 1 } { # verify if is a recursive DNS
if { not [CLASS::match $::IPADDR $::HOSTLIST ip] } {
# do something if IP isn't in the class_list, could be drop
} else {
# do other thing if IP is in the class_list
}
} else {
# do something if query is not recursive
}
}
I ended up having to create two class-lists, one with IP addresses that are allowed to recurse and one with locally-hosted zone files:
The locally hosted zone file list is required because by default, normal DNS queries have the RD bit set, so we needed to allow those requests through, even though they are locally hosted zone files.
I also needed to create a pretty much exact copy for IPv6 addresses, too. I wasn't sure if I'd be able to add both v4 and v6 into the same aFlex script, given that the script is applied on a per-VIP basis.