Forum Discussion
Joel_42834
Nimbostratus
Oct 19, 2012IP Address Validation with CIDR
How can a validate an IP address that is stored in a string data group that uses CIDR notation?
For dotted netmasks I use: [IP::addr $address mask $netmask]
where $address is say "...
nitass
Employee
Oct 19, 2012not sure if i understand your question correctly or not.
e.g.
[root@ve10:Active] config b class cidr_class list
class cidr_class {
{
"1.1.1.1/24"
"2.2.2.2/16"
}
}
[root@ve10:Active] config b rule myrule list
rule myrule {
when CLIENT_ACCEPTED {
foreach elm [class get cidr_class] {
if { [scan [lindex $elm 0] {%[^/]/%d} ip mask] == 2 } {
switch $mask {
16 { set mask_num "255.255.0.0" }
24 { set mask_num "255.255.255.0" }
}
log local0. "\[IP::addr [lindex $elm 0]\] = [IP::addr $ip mask $mask_num]"
}
}
}
}
[root@ve10:Active] config cat /var/log/ltm
Oct 19 17:47:50 local/tmm info tmm[7926]: Rule myrule : [IP::addr 1.1.1.1/24] = 1.1.1.0
Oct 19 17:47:50 local/tmm info tmm[7926]: Rule myrule : [IP::addr 2.2.2.2/16] = 2.2.0.0
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
