Forum Discussion

Raj_135327's avatar
Raj_135327
Icon for Nimbostratus rankNimbostratus
Apr 22, 2017

irule to resolve DNS query ( no dns licence on LTM)

I have a VIP to answer dns queries. This VIP forwards all dns queries to 8.8.8.8. Here is the deal i don't want it to forward dns queries say for example: to 8.8.8.8 and want this to be resolved to 1.1.1.1 and send the response to client. There's no dns licence on the LTM. Is it possible to do this with an irule with no dns license provisioned? We don't have GTM in our environment.

 

9 Replies

  • HI

    try this irule apply to your dns service virtual server

    when DNS_REQUEST {
        if { ([DNS::question name] equals "www.test1.com") } {
            DNS::answer insert "[DNS::question name]. 111 [DNS::question class] [DNS::question type] 1.1.1.1"
                DNS::return
                } else {
            discard
        }
    }
    

    have a good day!

  • Hi Raj,

    I tried oscarnet irule on a VE with only ASM and APM provisioned (Lab license)

    it work without GTM provisioned.

    Oscarnet's solution seems working except discard action in else statement you must remove.

    Here is a solution to support more than 1 record:

     when RULE_INIT {
        When removing values in array, the array must be unset to clear data.
        unset static::DNS_ARRAY
        array set static::DNS_ARRAY {
            "www.demo.local"    "1.1.1.1"
            "www2.demo.local"    "2.2.2.2"
        }
        set static::DNS_TTL 600
    }
    
    when DNS_REQUEST {
        if { [info exists static::DNS_ARRAY([DNS::question name])] } {
            DNS::answer insert "[DNS::question name]. $static::DNS_TTL [DNS::question class] [DNS::question type] $static::DNS_ARRAY([DNS::question name])"
            DNS::return
        }
    }