Forum Discussion

Ashish_Sharm_21's avatar
Ashish_Sharm_21
Icon for Nimbostratus rankNimbostratus
Jul 19, 2016

Direct traffic to node or pool via irule on the basis of list of ports

I need I-rule to direct the traffic only to pool/Node Server 06 if traffic related to port 15672, 4369, 25672, 5672, 5671, 61613, 61614, 1883, 8883 hit on the Virtual server.virtual server is with open with port 0 Is this right ?

 

if { ( [TCP::local_port] == 15672 ) or ( [TCP::local_port] == 4369 )or ( [TCP::local_port] == 25672 ) or ( [TCP::local_port] == 5672 ) or ( [TCP::local_port] == 61613 ) or ( [TCP::local_port] == 61614 ) or ( [TCP::local_port] == 1883 ) or ( [TCP::local_port] == 8834 ) } then { pool poola } else { [TCP::local_port] == 22 } { pool poolb }

 

1 Reply

  • in general you are right, there are some syntax issues with your code though, did you try it in the irule editor on the big-ip at all?

     

    this works for me:

     

    if { ( [TCP::local_port] == 15672 ) or ( [TCP::local_port] == 4369 ) or ( [TCP::local_port] == 25672 ) or ( [TCP::local_port] == 5672 ) or ( [TCP::local_port] == 61613 ) or ( [TCP::local_port] == 61614 ) or ( [TCP::local_port] == 1883 ) or ( [TCP::local_port] == 8834 ) } { 
        pool poola 
    }  elseif { ( [TCP::local_port] == 22) } { 
        pool poolb 
    }
    `
    
    still something with switch instead of if is probably cleaner and more readable
    
    `switch [TCP::local_port] {
      "1883" -
      "4369" -
      "5672" -
      "8834" -
      "15672" -
      "25672" -
      "61613" -
      "61614" {
        pool poola
      }
      "22" {
        pool poolb
      }
      default {
         don't do anything...
      }
    }