Forum Discussion

N_67263's avatar
N_67263
Icon for Nimbostratus rankNimbostratus
Aug 27, 2017

Node autoselection using DNS

Team, We are working on some designs which will help us choose a node directly of an F5 VIP once the VIP is hit.

 

e.g. externally a user will hit our F5 using URL "; the F5 needs to procees this request in such a way that it automatically selects a none xyz.internaldomain.com and forward the traffic directly to this node.

 

Here is the iRule we are trying to use:

 

when HTTP_REQUEST { get the IP(s) for the hostname set ips [lindex [RESOLV::lookup -a [HTTP::host]] 0] log local0. "Test: $ips" node $ips [TCP::local_port] }

 

Now, the logic here is that F5 looks at the IP address which is returned by the "host" field i.e. exclude the domain name. On the F5 itself we have set the domain lookup to be the internaldomain.com.

 

However, this does not seem to work and we are unable to understand what could be going incorrect here.

 

Any suggestions/recommendations?

 

Again, our end goal is to strip of the external domain name and use the internal domain name to do a lookup. The hostname will not change.

 

Thanks!! N.

 

1 Reply

  • Hi N,

    you should add some additional error handlings to your iRule in the case the browser doesn't send a HOST-Header value or in the case the DNS Server can't resolve the provided HOST-Name.

    when HTTP_REQUEST { 
        if { [HTTP::host] ne "" } then {
            set ips [lindex [RESOLV::lookup -a [getfield [HTTP::host] ":" 1]] 0]
            log local0.debug "Debug: Resolved address for \"[getfield [HTTP::host] ":" 1]\" = \"$ips\"" 
            if { $ips ne "" } then {
                node $ips [TCP::local_port]
            } else {
                HTTP::respond 504 content "Bad Request - non-existent HOST value"
            }
        } else {
            HTTP::respond 504 content "Bad Request - empty HOST value"
        }
    }
    

    Note: If the iRule above reports a "Bad Request - non-existent HOST value" in your environment, then make sure you've followed the steps outlined in K12225 [click me]. Alternatively to K12225 you could also setup a dedicated DNS Virtual Server and Pool to access and balance your DNS resolvers. Then use

    [RESOLV::lookup @VS_MyDNS -a [getfield [HTTP::host] ":" 1]] 0]
    to perform the DNS resolution via your just created Virtual Server...

    Cheers, Kai