Forum Discussion

Daniel_02_13867's avatar
Daniel_02_13867
Icon for Nimbostratus rankNimbostratus
Nov 29, 2013

persist for all but one IP address

Hi,

We have an iRule for persistence, where we want to skip running the persistence logic for a specific IP-address. The rule works great, but for the one thing that the IP-address check fails. Is something wrong with the snippet below?

if { ![IP::addr [IP::client_addr] equals 131.206.24.6] } {
    persist uie $persist_key 30
}

As described above, the "persist" statement is always executed. I have checked that the ip address is really the same address I am sending requests from - so I am guessing that it is something I am missing with the IP::addr comparison logic. What could be wrong?

3 Replies

  • Perhaps some brackets;

    if { !([IP::addr [IP::client_addr] equals 131.206.24.6]) } {
        persist uie $persist_key 30
    }
    

    Better yet (maybe);

    if { [IP::addr [IP::client_addr] equals 131.206.24.6] } {
      return }
    persist uie $persist_key 30
    
  • It seems to be that I did not specify any mask. I ended up generating some debut output and then performing string comparison, as I find it easier to reason about. So:

    if { ![string equal [IP::client_addr] 131.206.24.6%1] } {
        persist uie $persist_key 30
    }