Forum Discussion

Alejandro_Reyes's avatar
Alejandro_Reyes
Icon for Nimbostratus rankNimbostratus
Mar 10, 2011

fast DNS with two answers

Hi

 

 

Searching in the irule wiki home, i found a code called fast_dns. This irule can be applied to reply querys of an a particular host (FQDN) to client directly from the F5. http://devcentral.f5.com/wiki/default.aspx/iRules/fast_DNS.html

 

 

I configured this for a client, but in their particular case, it need that the answer for a host (FQDN) will be a couple of ip address. I tried to modify this irule but until this moment i can´t do it work .

 

 

Is there a way to configure it?

 

 

thanks in advance

 

 

3 Replies

  • Hi Erneri,

     

     

    try the new version...

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/fast_DNS_2.html

     

     

    what you need is customize static::domain and static::answer_string variable in RULE_INIT

     

     

    Nat
  • Nat,

     

     

    Thanks for your quick answer. I'll try to customize this irule with our custumer. Actually we resolved this with the next code

     

     

     

     

    when RULE_INIT {

     

    Header generation (in hexadecimal)

     

    qr(1) opcode(0000) AA(1) TC(0) RD(1) RA(1) Z(000) RCODE(0000)

     

    set ::header1 "8580"

     

    set ::header2 "8580"

     

    1 question, 1 answer, 0 NS, 0 Addition

     

    set ::header1 "${::header1}0001000200000000"

     

    set ::header2 "${::header2}0001000100000000"

     

    Name = www.f5.com

     

    set ::answer1 ""

     

    set ::answer2 ""

     

     

    Type = A

     

    set ::answer1 "${::answer1}0001"

     

    set ::answer2 "${::answer2}0001"

     

    Class = IN

     

    set ::answer1 "${::answer1}0001"

     

    set ::answer2 "${::answer2}0001"

     

    TTL = 1 day

     

    set ::answer1 "${::answer1}00015180"

     

    set ::answer2 "${::answer2}00015180"

     

    Data length = 4

     

    set ::answer1 "${::answer1}0004"

     

    set ::answer2 "${::answer2}0004"

     

    Address = 3.3.3.3

     

    set ::answer1 "${::answer1}01010101"

     

    set ::answer2 "${::answer2}02020202"

     

    log local0. "match init"

     

    }

     

    when CLIENT_DATA {

     

    binary scan [UDP::payload] H4@12A*@12H* id dname question

     

    set dname [string tolower [getfield $dname \x00 1 ] ]

     

    switch -glob $dname {

     

    "\x03www\x02f5\x03com" {

     

    set payload [binary format H* ${id}${::header1}${question}${::answer1}${::answer2} ]

     

    drop

     

    UDP::respond $payload

     

    UDP::payload replace 0 0 $payload

     

    }

     

    default {

     

    log local0. "does not match"

     

    }

     

    }

     

    }

     

     

     

     

    As soon as we test it, we´ll post our results

     

     

     

    Thanks again

     

     

    Regards

     

    erneri
  • Hi erneri,

     

     

    Are you on 10.x? If so, you can make the iRule CMP compatible by changing the global variables ($::header1, etc) to statics ($static::header1, etc).

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/CMPCompatibility.html

     

     

    Aaron