0.0.0.0 should be treated as valid IP address since it is possible to run service on this IP (which means "all interfaces and addresses") and connect to this address (using http://0.0.0.0:3000/ for local Rails applications works too). Another issue, addresses like A.B.C.0 CAN be valid if netmask (which is not taken in account in this checks) is greater than /24.
Function and regular expressions make only what is described in the commentary in the source text. You want real ip calculator? (english powered by translate.google.com)
Добавлено несколько функций: ipv4_ip_subnet ipv4_mask2prefix ipv4_prefix2mask