Forum Discussion

Tomi_Vojan's avatar
Tomi_Vojan
Icon for Nimbostratus rankNimbostratus
Aug 02, 2024

irule for DNS traffic

Hei 


We have to setup a DNS pointer in F5 for our web. User need to get the IP as per the region they login, if the login IP from Japan , they should get nearest loc IP. Please help to get a valid irule , pls? i tried so much, but nothing working as expected

 

Tomi 

3 Replies

  • Hi ,

     

    I have a irule and i already tested it my infra. 

     

    You have to configure Topology first in GTM(like below region(EMEA,NORTH_AMER,..)

    please note - i mentioned "Body" in some "else if", it means you have to fill if-else ladder inside that "elseif" like elseif(with actual pool). Please configure proper pool with matching location. 

     

    here if active member in your pool is greater than 1 only it fill forward traffic to a VIP. So there will be no down time :)

     

    when DNS_REQUEST {

      #log local0. "- (Request) Client: [IP::client_addr] - Request: [DNS::rrname] - Type: [DNS::rrtype] - Topology: [whereis [IP::client_addr]]"

    if { [matchregion [IP::client_addr] EMEA] } {

    if { [active_members pool1 ] >= 1 }

    { pool pool1 }

    elseif { [active_members pool2 ] >= 1 }

    { pool pool2 }

    else { pool pool3 }

    }

    elseif { [matchregion [IP::client_addr] NORTH_AMER] } {

    if { [active_members pool5 ] >= 1 }

    { pool pool5 }

    elseif { [active_members pool6 ] >= 1 }

    { pool pool6 }

    elseif { [active_members pool7 ] >= 1 }

    { pool pool7 }

    else { pool pool8 }

    elseif { [matchregion [IP::client_addr] SOUTH_AMER] } {

                   Body

    }

    elseif { [matchregion [IP::client_addr] OCEANIA] } {

                  Body

    }

    elseif { [matchregion [IP::client_addr] MIDDLE_EAST] } {

                  Body

    }

    elseif { [matchregion [IP::client_addr] ASIA] } {

                   Body

    }

    else {

                  Body

    }

    }