Forum Discussion

JP-814's avatar
JP-814
Icon for Nimbostratus rankNimbostratus
Dec 21, 2023

Assistance with iRule using port ranges

Hello all!

I currently have a VIP that is listening over various ports, 4400-4699. The owner of the app is having the client statically set a port when connecting to the VIP and would like to load balance to a particular member based on the port entered.

I built out an iRule for this and I am getting an error stating undefined procedure:tcp::local_port. Can I get some advice on what I am doing wrong here? Thanks in advance!

when CLIENT_ACCEPTED {
if { ( [TCP::local_port] > 4399 ) or ( [TCP::local_port] < 4499 ) } {
pool hjapp.portlist.pool member 10.11.20.52:0
} elseif { ( [tcp::local_port] > 4500 ) or ( [tcp::local_port] < 4700 ) } {
pool hjapp.portlist.pool member 10.11.20.58:0
}
}

  • it seems because you define the tcp port as ...:0 instead of 
    https://clouddocs.f5.com/api/irules/pool.html

    it will be tidier if you put .52 and and .58 in separate pools so you dont need to define pool member in the irule.
    you can use pool's priority group activation in each pool if you want both to be members.

    btw, it's better to use gui based traffic policy to avoid scripting typo

     

  • it seems because you define the tcp port as ...:0 instead of 
    https://clouddocs.f5.com/api/irules/pool.html

    it will be tidier if you put .52 and and .58 in separate pools so you dont need to define pool member in the irule.
    you can use pool's priority group activation in each pool if you want both to be members.

    btw, it's better to use gui based traffic policy to avoid scripting typo

     

    • JP-814's avatar
      JP-814
      Icon for Nimbostratus rankNimbostratus

      Oh wow, I didn't consider policy for this effort. That makes much more sense, thank you for that info! 😄

  • BTW, your iRule was 99% correct; it just had a slight typo:

    You just needed to amend the TCP::local_port command as it is case sensitive i.e:

    FROM
    tcp::local_port

    TO
    TCP::local_port