Forum Discussion

b_1's avatar
b_1
Icon for Altocumulus rankAltocumulus
Aug 13, 2019

Sending traffic to virtual server based on client IP

I'm looking to configure an irule that will direct traffic to one of two virtual servers I have under a WideIP entry. Basically when a request comes in if it's an IP address of 1.1.1.1 I want to send that client to Virtual Server 1 and if it's an IP address of 2.2.2.2 I want to send that client over to Virtual Server 2.

 

I've done something similar at the LTM level before - example below.

 

when CLIENT_ACCEPTED {

  if { [class match [IP::client_addr] equals CIDR/24] } {

    pool testpool

  }

}

  • Hello.

     

    You can do something like these examples

    https://clouddocs.f5.com/api/irules/DNS_REQUEST.html

     

    Also you can experimenting using split-DNS

    https://support.f5.com/csp/article/K14421

     

    KR,

    Dario.

  • Hello.

     

    You can do something like these examples

    https://clouddocs.f5.com/api/irules/DNS_REQUEST.html

     

    Also you can experimenting using split-DNS

    https://support.f5.com/csp/article/K14421

     

    KR,

    Dario.

    • b_1's avatar
      b_1
      Icon for Altocumulus rankAltocumulus

      So i've setup a split DNS iRule however for some reason, the client IP is not being matched to the IP entries in my datagroup. I've created two datagroups to see if the name was an issue but that didnt resolve the problem. If i switch the configuration to a known working datagroup, split DNS works perfectly. Any ideas? pulling my hair out.

  • Snl's avatar
    Snl
    Icon for Cirrostratus rankCirrostratus

    sample irule with datagroup

    when CLIENT_ACCEPTED {     
        if { [class match [IP::client_addr] equals datagroup1] } {        
            pool pool1             
            log local0. "[IP::client_addr] is 1"            
        } elseif { [class match [IP::client_addr] equals datagroup2] } {        
            pool pool2             
            log local0. "[IP::client_addr] is 2"            
        } else {        
             pool pool3              
             log local0. "[IP::client_addr] is 3"
        } 
    }