Forum Discussion

Mark_Bark_24174's avatar
Mark_Bark_24174
Icon for Nimbostratus rankNimbostratus
Jan 12, 2018

GTM Source IP Redirect to Specific Pools iRule

I'm trying to redirect clients to specific pools based on the clients IP address through an iRule. I created this iRule in the GTM and it seems to be working fine however, I'd like to set client networks in the rule instead of "starts_with" in an effort to keep this rule as short as we add more and more clients. I've tried "equals "10.80.0.0/16" however that didn't seem to work. Anyone have any ideas on what I could do to achieve my goal?

 

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

 

when DNS_REQUEST { if { [IP::client_addr] starts_with "10.80." } { pool pool_10_80 } elseif { [IP::client_addr] starts_with "10.96." } { pool pool_10_96 } elseif { [IP::client_addr] contains "172.27." } { pool pool_172_27 } }

 

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

 

Thanks in advance for any feedback.

 

  • You can use

    [IP::addr]
    so that you may use a CIDR mask notation for the subnet:

    https://devcentral.f5.com/wiki/iRules.IP__addr.ashx

    when DNS_REQUEST { 
        if { [IP::addr[IP::client_addr]] equals "10.80.0.0/16" } { 
            pool pool_10_80 
        } elseif { [IP::addr[IP::client_addr]] equals "10.96.0.0/16" } { 
            pool pool_10_96 
        } elseif { [IP::addr[IP::client_addr]] equals "172.27.0.0/16" } { 
            pool pool_172_27 
        } 
    }
    
  • GTM never sees real client IP but LDNS IP.

     

    if all internal users uses the same DNS server, the GTM will answer based on the DNS server IP.

     

  • Is there a way around this at all? I think this preventing the topology LB from working, from what im reading.