第一次遇到购买的小鸡要自己手工添加ipv6地址。

修改文件权限

chmod 600 /etc/netplan/*

此处不修改会报错误:Permissions for are too open

编辑网络配置文件

vi  /etc/netplan/50-cloud-init.yaml 
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: true
            match:
                macaddress: xx:xx:xx:xx:xx:xx
            set-name: eth0
    version: 2

修改为

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: true
            match:
                macaddress: xx:xx:xx:xx:xx:xx
            set-name: eth0
            dhcp6: false
            addresses: [替换为运营商给的IPV6地址/64]
            routes:
               - to: default
                 via: 替换为运营商给的IPV6网关地址
                 metric: 100
    version: 2

重启配置

netplan apply

查看并测试

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    altname xxxxx
    altname xxxx
    inet xxx.xxx.xxx.xxx/22 metric 100 brd xxx.xxx.xxx.xxx scope global eth0
       valid_lft forever preferred_lft forever
    inet6 运营商给的ipv6地址/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::f8c0:xxx:xxx:xxx/64 scope link 
       valid_lft forever preferred_lft forever

使用有ipv6的小鸡ping,ping通说明ipv6配置成功。

ping 运营商给的ipv6地址