Networkingflags: g
Private IP Address (RFC 1918)
Match IPv4 addresses in the RFC 1918 private ranges: 10/8, 192.168/16, and 172.16/12.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\b(?:10(?:\.\d{1,3}){3}|192\.168(?:\.\d{1,3}){2}|172\.(?:1[6-9]|2\d|3[01])(?:\.\d{1,3}){2})\b (flags: g)Raw source: \b(?:10(?:\.\d{1,3}){3}|192\.168(?:\.\d{1,3}){2}|172\.(?:1[6-9]|2\d|3[01])(?:\.\d{1,3}){2})\b
How it works
Three top-level alternatives cover the three reserved private ranges. 10(?:\.\d{1,3}){3} matches 10.x.x.x. 192\.168(?:\.\d{1,3}){2} matches 192.168.x.x. 172\.(?:1[6-9]|2\d|3[01]) constrains the second octet to the 16–31 sub-range, then (?:\.\d{1,3}){2} matches the last two octets. \b boundaries prevent partial-IP matches inside longer numbers.
Examples
Input
Servers at 10.0.0.5 and 192.168.1.20Matches
10.0.0.5192.168.1.20
Input
172.16.50.1 is private; 172.32.0.1 is notMatches
172.16.50.1
Input
Public IP 8.8.8.8No match
—Common use cases
- •Filtering log files for internal vs external traffic
- •Auditing firewall rules for unexpected public IPs
- •Network configuration validation
- •Telemetry redaction (drop external IPs from internal logs)
Related patterns
IP Address with CIDR Notation
NetworkingMatch IPv4 addresses with CIDR prefix notation such as 10.0.0.0/8 or 192.168.1.0/24.
IPv4 Address
NetworkingMatch valid IPv4 addresses with each octet constrained to 0–255.
Hostname (Single Label, RFC 1123)
NetworkingValidate a single-label hostname per RFC 1123: 1–63 chars, letters/digits/hyphens, can't start or end with hyphen.
IPv6 Address
NetworkingMatch full (non-compressed) IPv6 addresses written as eight colon-separated hextets.