Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

FQDN resolution and used in load balancing

Hello, I am working on requirement where I need to load balance traffic on FQDN. The FQDN is passed to F5 in HTTP header (Header name: backend-server). I have put iRule as below which is working fine.

when HTTP_REQUEST {

set lb_server [HTTP::header "backend-server"]
set lb_port [HTTP::header "backend-port"]
HTTP::header replace "Host" "$lb_server"
set dest [lindex [RESOLV::lookup @8.8.8.8 -a "$lb_server"] 0]
node $dest $lb_port

}

I would like to extend this further if FQDN is resolving in multiple IPs, use those IPs to load balance in round-robin or least connected fashion.

Would anyone know how this can be done? Any idea/suggestions?

Thank you.

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi,

Create a FQDN node and add the node to the load balancing pool.

The FQDN node list will auto populate all the nodes that are returned by the DNS query; they are called ephemeral nodes. You need to make sure your DNS server is set to return all A records for this to occur.

Cheers,

Kees

0
Comments on this Answer
Comment made 1 week ago by shishir.sontakke 7

Hello Kees van den Bos, thanks for the reply.

Yes I am aware of using FQDN nodes in pools through GUI but my requirement is to create it dynamically in iRule after reading header value. The header value will be passed to F5. The iRule I posted above is working fine if it resolves in single IP but I need to use it to load balance traffic if FQDN is resolving in multiple IPs. Thanks.

0
Comment made 1 week ago by Kees van den Bos 767

So create a pool per backend-server header and assign this pool based on the header

when HTTP_REQUEST {
    set lb_server [HTTP::header "backend-server"]
    HTTP::header replace "Host" "$lb_server"
    pool $lb_server
}

Cheers,

Kees

0
Comment made 1 week ago by shishir.sontakke 7

Wont this just create pool name with "$lb_server"? Or will this also add pool members in pool?

0
Comment made 1 week ago by Kees van den Bos 767

You need to create the pool with the same name as $lb_server and add the corresponding FQDN node and port to the pool.

0
Comment made 1 week ago by shishir.sontakke 7

Thats exactly I was looking for how can I add FQDN node in pool via iRule. I looked through lot of posting in DevCentral but couldnt find a way to add node/FQDN in pool via iRule.

0
Comment made 1 week ago by Kees van den Bos 767

As far as I know that's not possible.

Maybe this post can help you https://devcentral.f5.com/questions/create-a-node-based-on-an-event-63354

0
Comment made 1 week ago by shishir.sontakke 7

Thank you!!

0