Just wondering about the minimum character count of an IPv4 / IPv6 address in string representation. What's the shortest valid IP address?
What's the minimum length of an IP address in string representation?
Asked Answered
1.1.1.1
would be a valid IP address, so the answer to your question is "7".
This is not true. IP addresses can be represented in a variety of valid formats, some of which are shorter than this. (I'm looking for a reference right now.) EDIT: there don't appear to be any formats which are shorter than this. –
Perishable
If you can find a format that doesn't include all four octets, then I'd love to know what it is. And, BTW, if that was your downvote, it would have made better sense after you had posted an example of a shorter address format. –
Arterial
It was my downvote, and I haven't found a shorter format. I've upvoted now. Apologies. –
Perishable
Hmm, 1.0.0.0 would also be valid and could be expressed as
1
in hex - or am I missing something? –
Scyphus You are missing that that is not a valid format for the string representation of an IP address. –
Arterial
Is this still true?
::
is a valid IPv6 representation. –
Briggs ill take 7 as an answer, but id like to know the answer with port included –
Ate
@JohnSaunders You can omit the first 3 octets if they are zero. Try
ping 127.1
! –
Gaitskell The answer by @YvesDorfsman should be the accepted answer. –
Arterial
Technically, you can omit the first three octects if the are 0, therefore shortest ipv4 address is one byte, it is "1
", a shorthand for "0.0.0.1
".
© 2022 - 2025 — McMap. All rights reserved.