This article was posted as the 17th day article of IPv6 Advent Calendar 2019.
At the very least, wouldn't it be a problem if I knew this about IPv6 addresses? I wrote it appropriately. Accuracy? Don `t worry.
IPv4 divides the 32-bit address space every 8 bits with a. In decimal numbers.
For IPv6 addresses, the 128-bit address space is separated by ":" every 16 bits.
I will write it like this. Anyway, because the address space is wide, I try to write IPv6 addresses short by using hexadecimal notation, but since it is long after all, there are several abbreviation methods available to try to shorten it.
You can think of it as a way of writing by omitting consecutive 0s as much as possible [^ 1].
[^ 1]: See RFC5952-Recommended IPv6 Address Notation for detailed abbreviations.
Like this. Well, no matter what, the IPv6 address is long after all.
IPv6 addresses have various names depending on their behavior and scope of application. I feel that this is causing confusion, but even if you look at the same car, from what side you look at the car, whether it is called a "sports car", a "sedan", or a "FF car" It depends on what you are doing, right? The IPv6 address is the same. In this article
--Behavior --Scope --Special address
I would like to divide by.
--Unicast address --Address used on a one-to-one basis. In particular, it refers to a global address and is sometimes called a global unicast address. In IPv4, private addresses are called unique local addresses (ULA: Yueru) [^ 2]. Sometimes called a unique local IPv6 unicast address, but the shorter one.
--Multicast address --An address that represents a group. If you throw it to this address, it will be delivered to all the nodes that belong to that group. Used for one-to-many communication. Broadcast addresses in IPv4 have been abolished and integrated into multicast addresses. --Anycast address ――Well, don't worry
[^ 2]: Forget the old site local address as it is obsolete.
It distinguishes by which scope (range) the address is valid.
--Global address (currently 2000 :: / 3) --An address unique to the world. IPv6 addresses that start with 2 are generally OK if you think of them as so-called global addresses (although it's a lie [^ 3]) --Unique local address (ULA: fc00 :: / 7) --Also called a unique local IPv6 unicast address (substantially fd00 :: / 8 [^ 4]) --Link local address (fe80 :: / 10) --An address that is valid only within the link to which the node is directly connected. When the link goes up, it is given to the node without any questions. --The address starting with fe80 is that, like fe80 :: a00: 27ff: fef2: 2a39.
[^ 3]: Even if it starts from 2001, 2001: 0000 :: / 23 seems to be a special purpose address space, but it is spatially global. For more information, see IPv6 Global Unicast Address Assignments. Please give me.
[^ 4]: See RFC4193 for details. Usable addresses are randomly generated and used under certain conditions. Unlike IPv4 private addresses, the feature is that addresses do not basically collide. So be careful not to generate it with my rules! .. If you want to use it, go to ʻULA generator` or something!
Also, be careful about link-local addresses. Since the address is valid only in the link, if there are eth0, eth1, eth2, it is not possible to know which interface the address is on by looking at the address alone. So be sure to use it with the scope ID
$ ssh fe80::a00:27ff:fef2:2a39%eth1
In the above example,% eth1 represents the scope ID.
--Unspecified address - ::/128 --Something like 0.0.0.0/32 in IPv4. You use it with bind addresses! - ::/0 --The one like 0.0.0.0/0 in IPv4. You use it with default gw! --loopback address - ::1 --Something like 127.0.0.1 in IPv4 --Multicast to all nodes on the same link - ff02::1 --A guy like 192.0.2.255 in IPv4 --Multicast to all routers on the same link - ff02::2 --Is there anything similar in IPv4? --IPv4 projected address (also called IPv4-mapped address) - ::ffff:192.0.2.1 --Since the IPv6 address space is wide, the system in which the IPv4 address is embedded involuntarily --Even with an IPv6 socket, an IPv4 address can be treated internally as an IPv6 address for communication. But I'm not communicating with IPv6. --Not all operating systems support it. ――Well, you may see it in the log once in a while, but you should think about it like "Ah, this address is spit out, it supports IPv6."
# ip -6 addr show dev eth1 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000 inet6 2001:db8::cafe/64 scope global valid_lft forever preferred_lft forever inet6 2001:db8::a00:27ff:fef2:2a39/64 scope global dynamic valid_lft 86124sec preferred_lft 14124sec inet6 fe80::a00:27ff:fef2:2a39/64 scope link valid_lft forever preferred_lft forever
If you add a little explanation, it looks like this.
Sometimes when I enter an IPv6 address
Like this, pictograms are input. This is because it is batting with the pictogram notation by:, which is the delimiter of the IPv6 address. Originally, escaping with
\ should work, but with Qiita, it does not work, so
Like this, I think that it is easy to input by enclosing with `and it is good to input without stress.
For those who want to know more about IPv6, Distribute amazing IPv6 books for free! , I think you should download or purchase "Professional IPv6"! It seems that there will probably be no recommended books that cover IPv6 that exceed this in the future.