Forum Discussion

Misty_Spillers's avatar
Misty_Spillers
Icon for Nimbostratus rankNimbostratus
Sep 23, 2015

Need an iRule to choose pool by port.

First of all this isn't http traffic so I can't use the http profile. (I tried, doesn't work)

I basically need an iRule that says something like this. I'll just write in the parts I don't know the syntax for

when CLIENT_ACCEPTED {
if { if dst port less than 50000} {
pool Pool1
} else {
pool pool2 
}
}

Can someone help me with the syntax for "if dst port less than 50000" part.

Just to put it in other words. When the client tries to connect with a port less than 50000 send to pool1 and everything else to pool2

Thanks in advance!

Misty

10 Replies

  • Give this a try,

    when CLIENT_ACCEPTED {
        if {[TCP::local_port clientside] << 50000}{
            pool pool1
        }
        else {
            pool pool2
        }
    }
    
    • Misty_Spillers's avatar
      Misty_Spillers
      Icon for Nimbostratus rankNimbostratus
      Thank you for the quick response. If I wanted to look at source port instead, would I just change clientside to serverside? Sorry, the documentation I was given is confusing, want to make sure I could it either way. Thanks again!
    • Brad_Parker_139's avatar
      Brad_Parker_139
      Icon for Nacreous rankNacreous
      TCP::client_port would you give the clients source port. If you changed it to serverside, what you would have would be the source port of the LTM's connection to the backend server not the source port of the client's connection to the LTM.
  • Give this a try,

    when CLIENT_ACCEPTED {
        if {[TCP::local_port clientside] << 50000}{
            pool pool1
        }
        else {
            pool pool2
        }
    }
    
    • Brad_Parker's avatar
      Brad_Parker
      Icon for Cirrus rankCirrus
      updated to use TCP::local_port clientside as it is more appropriate.
    • Misty_Spillers's avatar
      Misty_Spillers
      Icon for Nimbostratus rankNimbostratus
      Thank you for the quick response. If I wanted to look at source port instead, would I just change clientside to serverside? Sorry, the documentation I was given is confusing, want to make sure I could it either way. Thanks again!
    • Brad_Parker's avatar
      Brad_Parker
      Icon for Cirrus rankCirrus
      TCP::client_port would you give the clients source port. If you changed it to serverside, what you would have would be the source port of the LTM's connection to the backend server not the source port of the client's connection to the LTM.