Forum Discussion

Shaker_347973's avatar
Shaker_347973
Icon for Nimbostratus rankNimbostratus
May 18, 2018

GTM load balancing based on source IPv6

I have an irule to balance DNS request based on even/odd last octe4t of the IPv4 address.

when DNS_REQUEST {
log local0. "GTM LOGGING: DNS request matching test.com  [IP::remote_addr] - QUESTION:[DNS::question name], [DNS::question type]"
            set ipaddress [lindex [split [IP::client_addr] "%"] 0]
set last [lindex [split $ipaddress "."] 3]
        log local0. "4th octect $last"
        if { ( $last%2 ) } { set destination odd } else { set destination even }
   if {$destination equals "even"}{
    pool pool1
 }
 else 
 pool pool2

I would need to have the similar irule to balance IPv6 based on the last hextet. Do you have any suggestion ?

1 Reply

  • Something like this:

    when DNS_REQUEST {
        log local0. "GTM LOGGING: DNS request matching test.com  [IP::remote_addr] - QUESTION:[DNS::question name], [DNS::question type]"
        set ipaddress [lindex [split [IP::client_addr] "%"] 0]
        set last [lindex [split $ipaddress ":"] 7]
        set lastdec [expr 0x$last]
        log local0. "8th hextet $last ($lastdec)"
        if { ( $lastdec%2 ) } { set destination "odd" } else { set destination "even" }
        if {$destination equals "even"} {
            pool pool1
        }
        else {
            pool pool2
        }
    }