Forum Discussion

Angelo's avatar
Angelo
Icon for Nimbostratus rankNimbostratus
Feb 22, 2013

DNS rewrite

Hi

 

 

I need a create a irule to rewrite a DNS entry i though it would be quite simple will i tried to write it LOL. basically i need to rewrite app.pac.com to app4.pac.com i thought about a simple redirect that would work but i just need to know if you can.

 

i read on the forum that it is possible but the code share links make no sense at all...

 

1 Reply

  • The tricky part is that the response also contains the question, so you have to change all instances of "app4.pac.com" back as the response passes by or the original requestor will reject it.

    You need to be running 11.1 or newer and have either GTM or DNS Services licensed for this rule to work:

    
    when DNS_REQUEST {
        if { [DNS::question name] eq "app.pac.com" } {
    DNS::question name app4.pac.com
        }
    }
    
    when DNS_RESPONSE {
        if { [ expr { [DNS::header rcode] eq "NOERROR"} ] && [ expr { [DNS::header ancount] > 0 } ] } {
    if { [DNS::question name] eq "app4.pac.com" } {
        DNS::question name app.pac.com
    }
    foreach a [DNS::answer] {
        if { [DNS::name $a] eq "app4.pac.com" } {
    DNS::name $a app.pac.com
        }
    }
        }
    }
     

    But since the effect of this rule is to create an alias, why don't you just use a CNAME entry in the dns zone file?