Forum Discussion

Ron_130795's avatar
Ron_130795
Icon for Nimbostratus rankNimbostratus
Mar 25, 2014

Need Assistance With Creating an iRule with different multiple ports for one VIP

I have a VIP that needs to respond to multiple ports. They are not in the same range so would my below iRule work?

 

when CLIENT_ACCEPTED { if {([TCP::local_port] = 799 ) && ([TCP::local_port] = 8914) || ([TCP::local_port] = 3000 ) && ([TCP::local_port] = 3050) } { pool Test_pool } else reject }

 

1 Reply

  • Hi, just to be clear you will need to create a VS with a single host and any port. Then add the iRule to control the connections to specific ports.

    To be clear, your iRule is not correct partly because it checks whether the TCP::local_port is two different numbers, which it can't be.

    This rule below also uses the switch statement which is more scalable than using if statements.

    when CLIENT_ACCEPTED { 
        switch [TCP::local_port]
        {
            799 { pool Test_pool }
            8914 { pool Test_pool }
            3000 { pool Test_pool }
            3050 { pool Test_pool }
            default { reject }
        }
    }