cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if a string parameter can be an IPv4 or an IPv6 or nothing in an iRule ?

Rodolphe_Aubin1
Nimbostratus
Nimbostratus

How to deal with that question in the best optimized way to code it versus cycles ?

"How to check if a string parameter can be an IPv4 or an IPv6 or nothing in an iRule ?"

 

I have already looked at "IP::addr .... mask ...scan ..." without any simple efficient way.

Some helps ? Some few lines ? or TCL function or undocumentated iRule command ?

 

Many thanks 🙂

2 REPLIES 2

PeteWhite
F5 Employee
F5 Employee

string matching with ip addresses is a bit wonky but you could simply do this:

if { $string equals "" } { # Empty string } elseif { $string contains "." } { # IPv4 } elseif { $string contains ":" } { # IPv6 } else { # error }

 

Rodolphe_Aubin1
Nimbostratus
Nimbostratus

Thank you Pete but a little bit too simple and too light 😉