Forum Discussion

Michael_C_16907's avatar
Michael_C_16907
Icon for Nimbostratus rankNimbostratus
Feb 01, 2010

TCL error in running iRule

I see Failures in my iRule:

 

 

TCL error: Rule Rules CLIENT_ACCEPTED - invalid command name TCP::port8 while executing TCP::port[TCP::local_port] equals 25

 

 

Here is my code.

 

 

when CLIENT_ACCEPTED {

 

if{([TCP::port[TCP::local_port] equals 25]) or ([TCP::port[TCP::local_port] equals 110]) or ([TCP::port[TCP::local_port] equals 1723]) or ([TCP::port[TCP::local_port] equals 1701])}{

 

use pool HGC_Persistent_GW

 

}elseif{[IP::addr [IP::local_addr] equals 118.143.13.0/24]}{

 

use pool HGC_Pool

 

}elseif{[IP::addr [IP::local_addr] equals 203.186.55.0/24]}{

 

use pool HKBN_Pool

 

}

 

}

 

 

Actually should it be just (TCP::local_port equals 110) insteed?

 

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    You're correct; you can just use TCP::local_port. There is no 'TCP::port' command. There is an IP::addr command to compare IP addresses. You could also replace the if chain with a switch statement:

     
     when CLIENT_ACCEPTED { 
      
         Check the client's requested port (the local port) 
        switch [TCP::local_port] { 
           "25" - 
           "110" - 
           "1723" - 
           "1701" { 
              pool HGC_Persistent_GW 
           } 
           default { 
              if {[IP::addr [IP::local_addr] equals 118.143.13.0/24]}{ 
                 pool HGC_Pool 
              } elseif {[IP::addr [IP::local_addr] equals 203.186.55.0/24]}{ 
                 pool HKBN_Pool 
              } 
           } 
        } 
     } 
     

    Aaron