On and on the questions go.
This article is intended to be a beginner’s guide to the anatomy of IPv4 and IPv6 addresses.
I’ll try to break things down in byte size pieces.
) But first:dig +short medium.
127——————————————–dig -tAAAA medium.
com | grep medium; <<>> DiG 9.
6 <<>> -tAAAA medium.
255 IN AAAA 2606:4700::6810:787fmedium.
255 IN AAAA 2606:4700::6810:7c7fmedium.
255 IN AAAA 2606:4700::6810:7a7fmedium.
255 IN AAAA 2606:4700::6810:7b7fmedium.
255 IN AAAA 2606:4700::6810:797fWhat does the IPv stand for in IPv4 and IPv6?Internet Protocol Version.
What happened to IPv1, IPv2, IPv3 and IPv5?In a time (1977) when the Internet was referred to as the “Internetwork” ❤, a discussion began regarding Internet Protocol:We are screwing up in our design of internet protocols by violating the principle of layering.
Specifically we are trying to use TCP to do two things: serve as a host level end to end protocol, and to serve as an internet packaging and routing protocol.
These two things should be provided in a layered and modular way.
I suggest that a new distinct internetwork protocol is needed, and that TCP be used strictly as a host level end to end protocol.
txtIn other words, TCP — or Transmission Control Protocol — wasn’t cutting the cake, and something new was needed.
Something that made the distinction between network-to-network (or “internetwork”) vs.
host level protocols.
The reason we don’t hear about IPv1, IPv2 and IPv3 is because IPv4 was the first stable version of Internet Protocol.
It transmitted datagrams with grace and poise, not to mention security and efficiency.
As for IPv5, it was an experimental real-time streaming protocol.
But due to the increase in IPv4 bandwidth over time, IPv5 became unnecessary.
Zeros and onesYou’ve probably heard it said that everything in a computer — all the videos you stream on YouTube, every key, every ‘like’ you click — ultimately boils down to zeros and ones.
The same thing could be said for IP addresses.
An IPv4 address has four sections, separated by dots:104.
127Each of these sections is made up of 8 bits.
What’s a bit?A bit is a zero or one.
The building block of computer language.
So the numbers you see in the IPv4 address above (for example: 104), could be written in binary.
(For some fun facts regarding binary and how bits flow through computer chips, check out Making Sense of Zeros and Ones.
)What is binary?Binary means communicating in zeros and ones (or bits).
Binary is a “base-2” numeral system.
This means it uses two digits: 0 or 1.
A bit is either off or on, 0 or 1.
(For context, decimal is a base-10 numeral system, and hexadecimal… well, we’ll get to that.
)IPv4 addresses range from 0.
0 to 255.
Why?As mentioned earlier, each section is made up of 8 bits.
Or eight zeros and ones.
Eight bits is equal to 1 byte, or could be referred to as an octet.
For example, this is an 8-bit number:01101000The above IPv4 address (104.
127) could be written in binary as follows:01101000.
01111111How does 01101000 represent the number 104?Each bit is weighted, from right to left, starting at 1 and increasing by a factor of 2.
For example:Bits: 0 1 1 0 1 0 0 0Weight: 128 64 32 16 8 4 2 1// To get 104, you'd only add up the weights that were switched "on", or that had the number 1 in their place:0110100064 + 32 + 8 = 104So when you hear someone say an IPv4 address is 32 bits in length, just think: 8 bits * 4 sections = 32 bits.
The anatomy of an IPv6 addressIPv6 addresses look a lot different.
For example:2606:4700::6810:787fIPv6 addresses use the hexadecimal numeral system.
What are hexadecimal numbers?The hexadecimal numeral system is base-16.
The doesn’t mean it goes 0-16.
Instead, it goes 0–9, then A-F (A: 10, B: 11, and so on).
As mentioned earlier, an IPv4 address contains four, 8-bit sections.
(Making it 32 bits in length.
) An IPv6 address, however, contains eight, 16-bit sections.
(For a grand total of 128 bits.
)But the IPv6 address listed above looks like it only has 4 (or 5?) sections.
What’s going on?This is something that has confused me for awhile.
So to provide some context, another way to write this IPv6 address would be:2606:4700:0000:0000:6810:787fThe reason you don’t include those additional zeros is because IPv6 addresses use something called zero compression (and zero suppression).
So if one (or more) of those sections contained all zeros, you could replace them with a colon.
This is called zero compression.
(Even if there were multiple sections of zeros — such as 0000:0000:0000:0000 — you’d still only use a double colon to represent all of the compressed zeros.
If one of those sections started with a zero — like 087f rather than 787f — you would remove the zero from the beginning, leaving you with 87f.
This is called zero suppression.
How would you write an IPv6 address in bits?As previously mentioned, there are eight, 16-bit sections in an IPv6 address.
Each 16-bit section is made up of four, 4-bit sections.
Let’s break this down by taking the first 4-bit section of the address above:// The complete address:2606:4700:0000:0000:6810:787f// The first section:2606// While IPv6 addresses are written using hexadecimal, each hexadecimal number is made up of 4 bits.
// In a 4-bit section, the number 2 would be written like this:0010Bits: 0 0 1 0Weight: 8 4 2 1// Therefore, the number 2606 in a 4-bit system would look like:0010.
0110How many possible IPv4 and IPv6 addresses are there?As you’ve probably heard, one of the reasons for moving to IPv6 is due to the near exhaustion of IPv4 addresses.
The total number of IPv4 addresses is 2³²:4,294,967,296.
(Just over four billion.
)For IPv6, it would be 2¹²⁸:340,282,366,920,938,463,463,374,607,431,768,211,456.
(340 undecillion? Beuller?)This is only a brief foray into the deep world of Internet Protocol.
For further nerd reading:The 1981 Internet Protocol written for DARPA (Defense Advanced Research Projects Agency):https://tools.
org/html/rfc791The Draft Internetwork Protocol Specification Protocol – Version 2 (IPv2):https://www.