Forum Discussion

carpey_13558's avatar
carpey_13558
Icon for Nimbostratus rankNimbostratus
Aug 17, 2007

Quick 4.X irule logic question

I want to separate traffic using an IP range and port number. I tried using a rule similar to the one shown, but was having issues. I think it may have something to do with the logic operators. Which operator takes precedence? Would putting parenthese help?

 

 

if ( client_addr equals 10.10.10.10 netmask

 

255.255.255.0 and server_port equals 80

 

or client_addr 10.10.9.10 netmask 255.255.255.0

 

and server_port equals 80 ) {

 

use pool pool1

 

}

 

else {

 

use pool pool2

 

}

 

 

Thanks,

 

Carpey
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Hi Carpey --

    Parentheses are your friend in this case, forcing the order of comparisons. Try this:
    if ( ((client_addr equals 10.10.10.10 netmask 255.255.255.0) and server_port equals 80)) or ((client_addr 10.10.9.10 netmask 255.255.255.0) and (server_port equals 80)) ) {
      use pool pool1
    }
    else {
      use pool pool2
    }

    HTH

    /deb