9 月 102021
 

获取时间戳

[root@s6 ~]# date +%s%N
1634089185225960225
[root@s6 ~]#

获取系统的唯一性ID

[root@s6 ~]# cat /etc/machine-id 
52e2104a451e6cc4c0cd3f75608ba59f
[root@s6 ~]#

通过hostnamectl查看

[root@s6 ~]# hostnamectl 
Static hostname: s6.linuxcache.com
Icon name: computer-vm
Chassis: vm
Machine ID: 52e2104a451e6cc4c0cd3f75608ba59f
Boot ID: 7b76dcb309d94c908ec297b10998cd38
Virtualization: kvm
Operating System: Fedora 34 (Server Edition)
CPE OS Name: cpe:/o:fedoraproject:fedora:34
Kernel: Linux 5.11.12-300.fc34.x86_64
Architecture: x86-64
Hardware Vendor: Vultr
Hardware Model: HFC
[root@s6 ~]#

拼接timestamp和machine-id并使用sha1算法计算校验值

printf <timestamp><machine-id> | sha1sum
printf 163408918522596022552e2104a451e6cc4c0cd3f75608ba59f | sha1sum

计算校验值

[root@s6 ~]# printf 163408918522596022552e2104a451e6cc4c0cd3f75608ba59f | sha1sum
e4819b79f35d65e8231cb7e23bf61fc76aab5571 -
[root@s6 ~]#

截取后5位16进制值

printf e4819b79f35d65e8231cb7e23bf61fc76aab5571 | cut -c 31-

截取成功

[root@s6 ~]# printf e4819b79f35d65e8231cb7e23bf61fc76aab5571 | cut -c 31-
c76aab5571
[root@s6 ~]#

拼接前缀

fd c7 6a ab 55 71
fdc7:6aab:5571::/64
使用ipcalc命令计算子网信息

[root@s6 ~]# ipcalc -6 fdc7:6aab:5571::/64
Full Network: fdc7:6aab:5571:0000:0000:0000:0000:0000/64
Network: fdc7:6aab:5571::/64
Netmask: ffff:ffff:ffff:ffff:: = 64

Address space: Unique Local Unicast
HostMin: fdc7:6aab:5571::
HostMax: fdc7:6aab:5571:0:ffff:ffff:ffff:ffff
Hosts/Net: 2^(64) = 18446744073709551616
[root@s6 ~]#

 

 

 

9 月 092021
 

原文

3.2.2. Sample Code for Pseudo-Random Global ID Algorithm

The algorithm described below is intended to be used for locally
assigned Global IDs. In each case the resulting global ID will be
used in the appropriate prefix as defined in Section 3.2.

1) Obtain the current time of day in 64-bit NTP format [NTP].

2) Obtain an EUI-64 identifier from the system running this
algorithm. If an EUI-64 does not exist, one can be created from
a 48-bit MAC address as specified in [ADDARCH]. If an EUI-64
cannot be obtained or created, a suitably unique identifier,
local to the node, should be used (e.g., system serial number).

3) Concatenate the time of day with the system-specific identifier
in order to create a key.

4) Compute an SHA-1 digest on the key as specified in [FIPS, SHA1];
the resulting value is 160 bits.

5) Use the least significant 40 bits as the Global ID.

6) Concatenate FC00::/7, the L bit set to 1, and the 40-bit Global
ID to create a Local IPv6 address prefix.

This algorithm will result in a Global ID that is reasonably unique
and can be used to create a locally assigned Local IPv6 address
prefix.

内容引用:

Unique Local IPv6 Unicast Addresses

9 月 062021
 

客户端标准配置文件

[Interface]
PrivateKey = 
Address = 172.16.0.1/24
DNS = 8.8.8.8, 8.8.4.4

[Peer]
PublicKey = 
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = hostname.com:51820
PersistentKeepalive = 25

生成二维码

方式1

$ qrencode -t ansiutf8 -r client.conf

方式2

$ qrencode -t ansiutf8 < client.conf

方式3

$ qrencode -t png -o client.png -r client.conf