Forum Discussion

Ian_Lohning_383's avatar
Ian_Lohning_383
Icon for Nimbostratus rankNimbostratus
Mar 19, 2014

Is it possible to use iRules to replicate a very basic DNS

Guys, I have a need to write up an irule that will be able to receive any DNS requests and always respond with the same IP address. ( The function is designed to work with a HTTP redirect function to redirect customers to an error page.).

Is this possible ? Could you provide a basic example?
                                            Thanks in advance

Ian Lohning +61 (0)419 561 774

3 Replies

  • John_Alam_45640's avatar
    John_Alam_45640
    Historic F5 Account

    Check out this page, it has examples: https://devcentral.f5.com/wiki/iRules.DNS__answer.ashx

     

    There are easier ways to redirect to an error page:

     

    1) Fallback URL in the HTTP profile.

     

    2) Priority groups

     

    3) HTTP::redirect http://1.2.3.4/Sorry.html

     

  • Thank you for your response, but it would be appreciated if you could address the question before providing alternative solutions.

     

    Is it possible to write an irule that will be able to receive any DNS requests and always respond with the same IP address? Could you provide a basic example?

     

    Thanks in advance Ian Lohning +61 (0)419 561 774

     

  • John_Alam_45640's avatar
    John_Alam_45640
    Historic F5 Account

    I did address the question before I provided alternatives. 🙂

    You missed this line:

    Check out this page, it has examples: https://devcentral.f5.com/wiki/iRules.DNS__answer.ashx

    Check out the link, there are examples. On an LTM you will need a DNS services license. On a GTM you are good to go.

    Here is one of the examples:

     Send one or more IP addresses for a response to an A query
     Use on an LTM virtual server with a DNS profile enabled
    when DNS_REQUEST {
         Log query details
        log local0. "\[DNS::question name\]: [DNS::question name],\
            \[DNS::question class\]: [DNS::question class], 
            \[DNS::question type\]: [DNS::question type]"
    
         Generate an answer with two A records
        DNS::answer insert "[DNS::question name]. 111 [DNS::question class] [DNS::question type] 1.1.1.1"
        DNS::answer insert "[DNS::question name]. 111 [DNS::question class] [DNS::question type] 1.1.1.2"
    
         Stop further processing of the query after this iRule and send the answer to the client
        DNS::return
    }
    

    HTH