IPV6链路地址分类

Aggregate global unicast address
可聚集全球单播地址 001x xxxx xxxx xxxx::
2400 0010 0100 0000 0000
2400:6180:0:d0::47f:1001/64
2400:6180:0:d0:0000:0000:47f:1001/64
#ping6 2400:6180:0:d0:0000:0000:47f:1001
PING 2400:6180:0:d0:0000:0000:47f:1001(2400:6180:0:d0::47f:1001) 56 data bytes
64 bytes from 2400:6180:0:d0::47f:1001: icmp_seq=1 ttl=64 time=3.23 ms

Unspecified address
IPv6中的未指定地址即0:0:0:0:0:0:0:0/128 或者::/128

Loopack address
IPv6中的环回地址即0:0:0:0:0:0:0:1/128 或者::1/128 相当于IPv4中的127.0.0.1/8,主要用于设备给自己发送报文。
#ping6 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.041 ms
64 bytes from ::1: icmp_seq=2 ttl=64 time=0.046 ms

Link Local Address 链路本地地址 FE80::/10(最高10位值为1111111010)(1111 1110 1000 0000)唯一本地单播地址
链路本地地址是IPv6中的应用范围受限制的地址类型,只能在连接到同一本地链路的节点之间使用。似于ipv4中,当DHCP分配失败时自动生成的类似于169.254.0.0/16这样的地址,凡是源地址或目的地址中含有link-local address的报文,路由器都不应当转发它,这样的报文只能在一个LAN中互通。

(ULA,unique local address)唯一区域地址FC00::/7(最高7位值为1111110) (1111 1100 0000 0000)
唯一本地地址是另一种应用范围受限的地址,它仅能在一个站点内使用。由于本地站点地址的废除(RFC3879),唯一本地地址被用来代替本地站点地址(RFC4193)
唯一本地地址的作用类似于IPv4中的私网地址,任何没有申请到提供商分配的全球单播地址的组织机构都可以使用唯一本地地址。

IPv6的组播与IPv4相同,用来标识一组接口,一般这些接口属于不同的节点。IPv6组播地址的前缀是FF00::/8
IPv6中没有为任播规定单独的地址空间,任播地址和单播地址使用相同的地址空间。

Server1:inet6 addr: fe80::250:56ff:fe90:32d8/64 Scope:Link
Server2:inet6 addr: fe80::250:56ff:fe90:4625/64 Scope:Link

#ping6 fe80::250:56ff:fe90:4625
connect: Invalid argument

ping6 -I eth0 fe80::250:56ff:fe90:4625
PING fe80::250:56ff:fe90:4625(fe80::250:56ff:fe90:4625) from fe80::250:56ff:fe90:32d8 eth0: 56 data bytes
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=1 ttl=64 time=2.02 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=2 ttl=64 time=0.169 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=3 ttl=64 time=0.147 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=4 ttl=64 time=0.224 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=5 ttl=64 time=0.187 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=6 ttl=64 time=0.172 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=7 ttl=64 time=0.157 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=8 ttl=64 time=0.153 ms

ping6 -I enp0s3 fe80::1
PING fe80::1(fe80::1) from fe80::1 enp0s3: 56 data bytes
64 bytes from fe80::1: icmp_seq=1 ttl=64 time=0.017 ms
64 bytes from fe80::1: icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from fe80::1: icmp_seq=3 ttl=64 time=0.032 ms

Google to the rescue, you have to specify the network interface you want to use to send the packet. It’s ok ping6 has a -I parameter that allows you to select the one you want, and you also find that there is a weird syntax that allows you to do that inline
fe80 (1)

fe80 (2)

Internet Protocol Version 6 (IPv6)地址计算

Internet Protocol Version 6 (IPv6)地址块计算
IPv6 地址块:2602:ffea:1002:12::/64

在很多场合,IPv6地址由两个逻辑部分组成:一个64位的网络前缀和一个64位的主机地址
IPv6 addresses consist of two parts. The most-significant 64 bits are the subnet prefix to which the host is connected, and the least-significant 64 bits are the identifier of the host interface on the subnet.

Autoconfigured address format
part Subnet prefix Interface identifier
bits 64 64

IPv6 地址块:2602:ffea:1002:12::/64 计算
IP Information
IP Type IPv6
CIDR 2602:ffea:1002:12::/64
Uncompressed CIDR 2602:ffea:1002:0012:0000:0000:0000:0000/64
Network Bits 64
Minimum IP 2602:ffea:1002:12::
Gateway 2602:ffea:1002:12::1
Primary IP 2602:ffea:1002:12::2
Last Usable IP 2602:ffea:1002:12:ffff:ffff:ffff:fffe
Maximum IP 2602:ffea:1002:12:ffff:ffff:ffff:ffff
Uncompressed Minimum IP 2602:ffea:1002:0012:0000:0000:0000:0000
Uncompressed Gateway 2602:ffea:1002:0012:0000:0000:0000:0001
Uncompressed Primary IP 2602:ffea:1002:0012:0000:0000:0000:0002
Uncompressed Last Usable IP 2602:ffea:1002:0012:ffff:ffff:ffff:fffe
Uncompressed Maximum IP 2602:ffea:1002:0012:ffff:ffff:ffff:ffff
Number of Usable IPs 18446744073709551615
除了做Gateway的地址,其他地址都可以使用,IPv6地址中主机地址段全为0或者全为都1是合法的。
Configurable Address Range: 2400:6180:0:d0::47f:1000 - 2400:6180:0:d0::47f:100f

Internet Protocol Version 6 配置
IPv6 calculate (1)

IPv6 calculate (2)

IPv6 calculate (4)

IPv6 calculate (3)
use IPv6

配置单个IPV6地址和批量配置多个IPv6地址


配置单个IPV6地址和批量配置多个IPv6地址

IPv6(Internet Protocol Version 6)
IPv6为128位二进位制,为方便表示规定以16位二进制为一组,每组以冒号":"隔开,可以分为8组,每组以4位十六进制方式表示。
16位二进制 * 8 128位二进制 1111 1111 1111 1111::
4位十六进制 *8 32位十六进制 1 1 1 1::
如果几个连续段位的值都是0,那么这些0就可以简单的以::来表示,在一个IPv6地址中只能用一次。
2604:a880:1:20::48:c001/64
2604:a880:1:20:0000:0000:48:c001/64
2604:a880:0001:0020:0000:0000:0048:c001/64

#cat ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
HWADDR=04:01:42:a0:03:01
IPADDR=104.131.158.120
NETMASK=255.255.240.0
GATEWAY=104.131.144.1
NM_CONTROLLED='yes'
IPV6INIT=yes
IPV6ADDR=2604:A880:0001:0020:0000:0000:0048:C001/64
IPV6_DEFAULTGW=2604:A880:0001:0020:0000:0000:0000:0001
IPV6_AUTOCONF=no
DNS1=2001:4860:4860::8844
DNS2=2001:4860:4860::8888
DNS3=8.8.8.8

为CentOS/Redhat/Fedora批量添加多个IPv6地址
IPV6ADDR_SECONDARIES="2604:a880:1:20:0000:0000:48:c002/64 \
2604:a880:1:20:0000:0000:48:c003/64 \
2604:a880:1:20:0000:0000:48:c004/64 \
2604:a880:1:20:0000:0000:48:c005/64"
IPV6_DEFAULTGW=2604:A880:0001:0020:0000:0000:0000:0001
----------------------
SHELL 批量配置多个IPv6地址

#!/bin/bash
INETP="2607:f0d0:1002:11::"
PRE="64"
START=2
END=200
INT_IF="eth0"
IFCONFIG=/sbin/ifconfig
echo -n "Adding IPv6 Alias..."
for i in {$START..$END}
do
$IFCONFIG $INT_IF inet6 add ${INETP}${i}/${PRE}
done
echo "Done!"
------------------
2001:19f0:7000:8de2:5400:ff:fe1a:2ca/64 这是一个ipv6地址,/64主要是用于路由网段,路由的路径选择。
------------------
IP Information

IP Type IPv6
CIDR 2604:a880:1:20::/64
Network Bits 64
Minimum IP 2604:a880:1:20::
Gateway 2604:a880:1:20::1
Primary IP 2604:a880:1:20::2
Last Usable IP 2604:a880:1:20:ffff:ffff:ffff:fffe
Maximum IP 2604:a880:1:20:ffff:ffff:ffff:ffff
Number of Usable IPs 18446744073709551615
------------------
6TO4 Adapter:

连接特定的 DNS 后缀 . . . . . . . :
IPv6 地址 . . . . . . . . . . . . : 2002:7b0b:ca39::7b0b:ca39
默认网关. . . . . . . . . . . . . : 2002:c058:6301::c058:6301

Internet Protocol Version 6 (1)

Internet Protocol Version 6 (2)

Internet Protocol Version 6 (3)


2001:19f0:7000:8de2:5400:ff:fe1a:2ca/64 这是个ipv6地址,/64主要是用于路由网段,路由的路径选择。