Skip to content
IP-033 IP Addresses & Networks

Is this actually a valid and complete IP address?


title: "Is this actually a valid and complete IP address?" card_id: "IP-033" status: "complete" source_document: "https://docs.google.com/document/d/1JBuA6Bc2HJfJwxy5N4Lud_AF52Zfp8rfiEwMiAcGf64/edit?usp=drivesdk"


Is this actually a valid and complete IP address?

Is this actually a valid and complete IP address?

Before trying to resolve or interpret an IP address, check that the value is actually a valid and complete address.

An IPv4 address is normally written as four numbers separated by full stops.

For example:

203.0.113.25

Each number must be between zero and 255.

A value containing too many or too few sections, an empty section or a number greater than 255 isn't a valid ordinary IPv4 address.

For example, 203.0.113 is incomplete, while 203.0.113.300 contains a number outside the permitted range.

Sometimes an IPv4 address is followed by a colon and a port number.

For example:

203.0.113.25 colon 51,543.

The port isn't part of the IP address. It is additional connection information and should be preserved separately.

IPv6 addresses look different.

They use hexadecimal characters—zero to nine and A to F—and sections separated by colons.

An IPv6 address may contain a double colon, which compresses one or more sections containing zeros. This means that two IPv6 addresses can look different while representing the same underlying value.

However, a double colon can normally appear only once within a valid address. A copied IPv6 address with missing colons, invalid characters or part of the value removed may be unusable.

IPv6 addresses are sometimes placed inside square brackets when shown with a port.

For example:

open bracket, 2001 colon db8 double colon 25, close bracket, colon 443.

The value inside the brackets is the IPv6 address. The final 443 is the port.

A slash followed by a number has another meaning.

For example, an address ending slash 24 or slash 64 usually describes a network prefix or range. It doesn't necessarily identify one individual address.

Watch for values that have been shortened, redacted or anonymised.

An address containing stars, the letter X or text such as “address removed” may show only part of the original value. A screenshot may also crop the end of an IPv6 address or make characters difficult to distinguish.

Hostnames, web addresses and account identifiers may appear beside an IP address but aren't themselves IP addresses.

A syntactically valid address isn't necessarily a publicly attributable address. It could still be private, loopback, link-local or reserved for another purpose. That is a separate question.

The value should be preserved exactly as it appeared in the original record, including any accompanying port, brackets or prefix length.

If an IP address is incomplete or incorrectly transcribed, a lookup may fail—or worse, return information about a different address. Validation should therefore happen before attribution begins.


Keep moving

Where this question leads

These links explain why the next page may matter, rather than presenting an undifferentiated list.