Forum Discussion

____177053's avatar
Nov 29, 2016

How to use irules to do like this

How to use irules to do like this : We have an ip like:123.12.3.5 How to get the string like:123.12.3

 

Thanks a lot!

 

1 Reply

  • Let us say that you are operating on the client IP:

    set reduced [string range $ip 0 [expr { [string last . [IP::client_addr]] - 1 }]]
    

    This is ~20% faster than a variant:

    set reduced [join [lrange [split [IP::client_addr] .] 0 2] .]