What's the minimum length of an IP address in string representation?
Asked Answered
M

2

8

Just wondering about the minimum character count of an IPv4 / IPv6 address in string representation. What's the shortest valid IP address?

Mareah answered 9/3, 2014 at 21:35 Comment(0)
A
12

1.1.1.1 would be a valid IP address, so the answer to your question is "7".

Arterial answered 9/3, 2014 at 21:37 Comment(9)
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 includedAte
@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
G
7

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".

Gaitskell answered 20/1, 2021 at 1:18 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.