Forum Discussion

omar_padilla's avatar
omar_padilla
Icon for Altocumulus rankAltocumulus
Mar 09, 2018

Allow some DNS queries and block the rest

Hello,

 

I want and irule to just allow some DNS queries and block the rest.

 

I was trying with this that blocks some dns request and permit the rest

 

when DNS_REQUEST { switch -glob [string tolower [DNS::question name]] { "*.google.com" - "google.com" { DNS::header rcode NXDOMAIN DNS::return } } }

 

But I can not negate it and make it works in the other way.

 

Any idea how I could do this?

 

Thanks in advanced

 

  • Surgeon's avatar
    Surgeon
    Ret. Employee

    what do you mean by saying "make it works in the other way"?

     

  • In switch command, do nothing in conditions you want to allow and block in default condition

    when DNS_REQUEST {
        switch -glob [string tolower [DNS::question name]]  {         
            "*.google.com" -        
            "google.com" {        
                  do nothing       
            }        
            default {        
                DNS::header rcode NXDOMAIN             
                DNS::return             
            }            
        } 
    }