Forum Discussion

ggarza_345867's avatar
ggarza_345867
Icon for Nimbostratus rankNimbostratus
Jul 20, 2018

iRule is giving bracket errors but cant find it were.

iRule is giving bracket errors but cant find it were.

 

!

when DNS_REQUEST { switch [IP::remote_addr] { "192.168.163.0/24 “ { if { [LB::status vs 192.168.163.39] eq "up" } {

 

host 192.168.163.39

 

} else { host 192.168.204.45

 

} }

 

"192.168.165.0/24] " { if { [LB::status vs 192.168.163.39] eq "up" } {

 

host 192.168.163.39 } else { host 192.168.204.45 } } "192.168.204.0/24] " { if { [LB::status vs 192.168.204.45] eq "up" } {

 

host 192.168.204.45 } else { host 192.168.163.39 } } } }

 

  • Written iRule with help of if & elseif condition. Please check & let us know if any confusion.

       when DNS_REQUEST { 
        if { [IP::addr [IP::remote_addr] equals 192.168.163.0 mask 255.255.255.0]} {
            if {[LB::status vs 192.168.163.39 ] eq "up" } {
                    host 192.168.163.39 } 
            else { 
                host 192.168.204.45 }
        elseif { [IP::addr [IP::remote_addr] equals 192.168.165.0 mask 255.255.255.0]} {
            if {[LB::status vs 192.168.163.39] eq "up" } { 
                host 192.168.163.39 }
            else { 
                host 192.168.204.45 }
        elseif { [IP::addr [IP::remote_addr] equals 192.168.204.0 mask 255.255.255.0]} { 
                        if { [LB::status vs 192.168.204.45] eq "up" } { 
                host 192.168.204.45 } 
            else { 
                host 192.168.163.39 }
                    }
            }
            }
    

    hope it will help

    • ggarza_345867's avatar
      ggarza_345867
      Icon for Nimbostratus rankNimbostratus

      Still doesn't work, still getting close bracket errors.. I'm trying to use the switch command to create three separate checks on source IP's

       

      when DNS_REQUEST { switch [IP::remote_addr] { "192.168.163.0/24 “ { if { [LB::status vs 192.168.163.39] eq "up" } {

       

      host 192.168.163.39

       

      } else { host 192.168.204.45

       

      } } "192.168.165.0/24] " { if { [LB::status vs 192.168.163.39] eq "up" } {

       

      host 192.168.163.39 } else { host 192.168.163.39 } } "192.168.204.0/24] " { if { [LB::status vs 192.168.204.45] eq "up" } {

       

      host 192.168.204.45 } else { host 192.168.163.39 } }

       

    • Samir_Jha_52506's avatar
      Samir_Jha_52506
      Icon for Noctilucent rankNoctilucent

      Can you please try now...

          when DNS_REQUEST {
              switch [IP::remote_addr] {
                "192.168.163.0/24 “ {
      if { [LB::status vs 192.168.163.39] eq "up" } {   
         host 192.168.163.39 } 
         else { host 192.168.204.45 }
      }
        "192.168.165.0/24] " {
      if { [LB::status vs 192.168.163.39] eq "up" } {
          host 192.168.163.39 } 
          else { host 192.168.163.39 }
      }
       "192.168.204.0/24] " {
      if { [LB::status vs 192.168.204.45] eq "up" } {
         host 192.168.204.45 } 
         else { host 192.168.163.39 }
          }
      }  
      
    • ggarza_345867's avatar
      ggarza_345867
      Icon for Nimbostratus rankNimbostratus

      Nope..still failing the iRule editor. I was getting some closed bracket errors, I added couple more at end to clear up. But now getting "invalid list element in quotes followed by "up" instead of space