Address Family Detector

Detect if an address is IPv4, IPv6, or invalid

Input IP Addresses

Detection Results

Detection results will appear here

The Address Family Detector instantly identifies whether an IP address string is IPv4, IPv6, or invalid. Enter any address like 192.168.1.1, 2001:db8::1, or ::ffff:10.0.0.1 to see its detected family, validation status, and any format issues. The tool provides the essential first-step classification needed before processing addresses in scripts, applications, firewall rules, or configuration files.

Understanding IP Address Families

Every IP address belongs to one of two protocol families: IPv4 or IPv6. They look completely different, they are parsed by different code paths, and they are handled by different protocol stacks in the operating system. Before you can do anything useful with an address -- validate it, look up its geolocation, check if it is private, or add it to a firewall rule -- you need to know which family it belongs to. This seems obvious when you look at 192.168.1.1 versus 2001:db8::1, but edge cases make automated detection trickier than you might expect.

The complications arise from formats that blur the line between families. An IPv4-mapped IPv6 address like ::ffff:192.168.1.1 contains what looks like an IPv4 address, but it is technically a 128-bit IPv6 address. An IPv4-compatible address like ::192.168.1.1 is also IPv6, despite the dotted decimal at the end. Zone IDs like fe80::1%eth0 add a non-numeric suffix that some parsers choke on. CIDR notation like 192.168.1.0/24 includes a prefix length that is not part of the address itself. And inputs like 192.168.1.256 look like IPv4 but fail validation because the octet exceeds 255.

This detector handles all of these cases. It examines the structure and characters of the input, classifies it into the correct family, and then validates the address against that family's rules. For invalid inputs, it tells you not just that the address is invalid but why -- missing octets, out-of-range values, non-hex characters, double :: compression, or other specific issues. This makes it a useful debugging tool when you are trying to figure out why an address that "looks right" is being rejected by some other system.

How to Detect if an Address Is IPv4 or IPv6

  1. Enter any IP address string (e.g., 192.168.1.1, 2001:db8::1, or ::ffff:10.0.0.1)
  2. The tool analyzes the format and classifies it as IPv4, IPv6, or invalid
  3. View the detected address family along with validation details
  4. For invalid inputs, see the specific reason for the failure (out-of-range octet, malformed notation, etc.)

Address Family Detection Examples

InputDetected FamilyValidNotes
192.168.1.1IPv4YesStandard dotted decimal
2001:db8::1IPv6YesCompressed notation
::ffff:192.168.1.1IPv6YesIPv4-mapped IPv6
fe80::1%eth0IPv6YesLink-local with zone ID
10.0.0.1IPv4YesPrivate address
::1IPv6YesLoopback
192.168.1.256IPv4NoOctet exceeds 255
2001:db8::xyzIPv6NoNon-hex character
helloNeitherNoNot an IP address
192.168.1NeitherNoMissing octet
1.2.3.4.5NeitherNoToo many octets
2001:db8::1::2IPv6NoMultiple ::

Why Use the Address Family Detector

  • Input validation -- determine the address family before routing input to IPv4-specific or IPv6-specific processing logic in scripts and applications
  • Mixed-format data handling -- process address lists that contain a mix of IPv4 and IPv6 entries by classifying each entry first
  • Configuration debugging -- verify whether a string that looks like an IP address is actually valid before adding it to firewall rules or DNS records
  • Log parsing -- classify addresses extracted from multi-format log files to apply the correct analysis pipeline
  • API input sanitization -- reject malformed address strings at the entry point before they cause downstream errors
  • Migration planning -- audit address lists to understand the IPv4/IPv6 mix before planning dual-stack or IPv6-only deployments

How IP Address Family Detection Works

Address family detection examines the structure and characters of the input string to determine which IP version it represents, then validates the format against that version's rules.

IPv4 Detection Rules

An input is classified as IPv4 if it matches these criteria:

  • Contains exactly three dots separating four numeric groups
  • Each group (octet) is a decimal number between 0 and 255
  • No leading zeros in octets (strict mode) -- 010.0.0.1 may be rejected because 010 could be interpreted as octal 8
  • No characters other than digits and dots
Valid:    192.168.1.1    10.0.0.255    0.0.0.0
Invalid:  192.168.1.256  (octet > 255)
Invalid:  192.168.1      (only 3 octets)
Invalid:  192.168.1.1.5  (5 octets)

IPv6 Detection Rules

An input is classified as IPv6 if it matches these criteria:

  • Contains colons separating hexadecimal groups (hextets)
  • Up to eight groups of 1-4 hex digits each
  • May use :: to compress consecutive groups of zeros (only once)
  • May include a zone ID suffix (%eth0) for link-local addresses
  • May use mixed notation for IPv4-mapped addresses (::ffff:192.168.1.1)
Valid:    2001:db8::1
Valid:    ::ffff:10.0.0.1
Valid:    fe80::1%eth0
Invalid:  2001:db8::1::2   (double :: not allowed)
Invalid:  2001:db8::gggg   (non-hex character)

Edge Cases

Several address formats require special handling:

  • IPv4-mapped IPv6 (::ffff:192.168.1.1) -- detected as IPv6, not IPv4, because it uses IPv6 notation even though it contains an IPv4 address
  • IPv4-compatible IPv6 (::192.168.1.1) -- detected as IPv6; this format is deprecated per RFC 4291
  • Zone IDs (fe80::1%eth0) -- the % suffix is part of the IPv6 address specification for scoped addresses and should not cause rejection
  • CIDR notation (192.168.1.0/24) -- the /prefix portion is not part of the address itself; some implementations strip it before detection

Practical Advice for Address Family Handling

When building applications or scripts that process IP addresses, the most robust approach is to detect the address family at the earliest possible point in your pipeline and then branch into family-specific logic. Trying to write a single regex or parser that handles both IPv4 and IPv6 correctly is a common source of subtle bugs. IPv6 alone has multiple valid representations for the same address (expanded, compressed, mixed notation), and IPv4 has edge cases with leading zeros and octal interpretation. Use your language's standard library -- Python's ipaddress module, Go's net package, Java's InetAddress class -- rather than rolling your own parser.

A particularly insidious bug occurs when applications treat IPv4-mapped IPv6 addresses as pure IPv6. If a security check compares against an IPv4 blocklist but the address is presented in mapped form (::ffff:10.0.0.5), the comparison fails and the blocklist is bypassed. Your detection logic should recognize mapped addresses and extract the IPv4 portion for any IPv4-specific checks. This is not an academic concern -- it has been the root cause of real-world security vulnerabilities.

Leading zeros in IPv4 addresses deserve special attention. The string 010.0.0.1 looks like 10.0.0.1 to a human, but some programming languages and systems interpret 010 as octal 8, resolving the address to 8.0.0.1 instead. This discrepancy has been exploited in SSRF (Server-Side Request Forgery) attacks where a blocklist checks the decimal interpretation but the HTTP client uses the octal interpretation. Strict validation that rejects leading zeros eliminates this entire class of vulnerability.

Frequently Asked Questions

Why is ::ffff:192.168.1.1 detected as IPv6 instead of IPv4?

Because ::ffff:192.168.1.1 uses IPv6 notation (colons) and is a valid 128-bit IPv6 address. The fact that it contains an embedded IPv4 address does not change its address family. It is an IPv4-mapped IPv6 address, which is a specific type within the IPv6 family. Use the IPv4-Mapped IPv6 Converter to extract the IPv4 portion.

How does the detector handle leading zeros in IPv4 octets?

In strict validation mode, leading zeros like 010.0.0.1 may be rejected because some systems interpret 010 as octal (decimal 8) rather than decimal 10. This ambiguity can lead to security vulnerabilities where an address resolves to an unintended destination. The detector flags this as potentially invalid to prevent such issues.

Can the detector identify the specific type within a family (private, public, multicast)?

The Address Family Detector focuses on family classification (IPv4 vs. IPv6 vs. invalid). For more detailed type classification, use the IPv4 Private/Public Detector or the IPv6 Unique Local/Link-Local Detector after determining the family.

How should I handle addresses with CIDR notation like 192.168.1.0/24?

The /24 prefix length is not part of the IP address itself -- it describes the subnet size. Most address parsing libraries strip the CIDR suffix before validation. If your input may contain CIDR notation, split on the / character first, validate the address portion, and handle the prefix length separately.

What is the most common cause of invalid address detection?

For IPv4, the most common issue is an octet value exceeding 255 (e.g., 192.168.1.300) or an incorrect number of octets. For IPv6, the most common issue is using :: more than once (e.g., 2001:db8::1::2) or including non-hexadecimal characters. Both types can also be invalid due to incorrect formatting like trailing dots or colons.

Related Tools

IPparseβ€’Free Network & Subnet Calculator Tools

Β© 2026 IPparse. All tools run locally in your browser.

100% Privacy-First β€’ No Data Collected