Skip to main content
AllDevToolsHub
Back to all patterns

IPv4 CIDR Block

Web & Network

Validates an IPv4 address with a /0–/32 CIDR suffix.

/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(?:3[0-2]|[12]?[0-9])$/

How it works

Combines an octet-bounded IPv4 pattern with a 0–32 mask. Useful for parsing routing tables, firewall rules, and VPC subnets.

Test Cases

Should Match

  • 10.0.0.0/8
  • 192.168.1.0/24
  • 0.0.0.0/0
  • 255.255.255.255/32

Should NOT Match

  • 10.0.0.0/33
  • 10.0.0.0
  • 10.0.0.0/-1

Quick Summary

Matches a properly bounded IPv4 CIDR block (a.b.c.d/0–32).