For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Mariusz_B's avatar
Mariusz_B
Icon for Nimbostratus rankNimbostratus
Feb 02, 2015

Address Data Group with switch option in iRule.

Hello,

I have the following iRule:

when DNS_REQUEST {
  switch [IP::remote_addr] {   
 Client 1     
  "10.10.10.0/24" {
    if {[LB::status vs Client1] eq "up" } {     
        host 1.1.1.1
      } else {
        host 2.2.2.2
      }
   }
  "10.10.20.0/24" {
   if {[LB::status vs Client1] eq "up" } {  
        host 1.1.1.1
      } else {
        host 2.2.2.2
      }
  } 
   "10.10.30.0/24" {
    if {[LB::status vs Client1] eq "up" } {  
        host 1.1.1.1
      } else {
        host 2.2.2.2
      }
   }

 Client 2    
   "10.20.10.0/24" {
    if {[LB::status vs Client2] eq "up" } {     
        host 1.1.1.1
      } else {
        host 2.2.2.2
      }
   }
  "10.20.20.0/24" {
   if {[LB::status vs Client2] eq "up" } {  
        host 1.1.1.1
      } else {
        host 2.2.2.2
      }
  } 
   "10.20.30.0/24" {
    if {[LB::status vs Client2] eq "up" } {  
        host 1.1.1.1
      } else {
        host 2.2.2.2
      }
   } 
 }
}

Is it possible to use address group list instead of network subnet, so I can have only one "if" statement per client?

Regards

Mariusz

1 Reply

  • Best way may be like this...

    when DNS_REQUEST {
         Get the status
        switch [IP::remote_addr] {   
            "10.10.10.0/24" -
            "10.10.20.0/24" -
            "10.10.30.0/24" {
                set status [LB::status vs Client1]
            }
            "10.20.10.0/24" -
            "10.20.20.0/24" -
            "10.20.30.0/24" {
                set status [LB::status vs Client2]
    
            } 
        }
    
         Handle the status
        if {$status equals "up"} {
            host 1.1.1.1
        } else {
            host 2.2.2.2
        }    
    }