Ubuntu16.04和debian单网卡配置多IPv6地址

注意:在此之前必须先分配好网络地址,才能添加。

一、修改/etc/network/interfaces 文件内容

 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface

auto eth0
iface eth0 inet dhcp
pre-up sleep 2
#以下是第一个IPv6地址
iface eth0 inet6 static
address 2605:6400:0120:1b99::2
netmask 48
gateway 2605:6400:120::1

#以下是第二个IPv6地址
auto eth0:0
iface eth0:0 inet6 static
address 2605:6400:0120:1b99::3
netmask 48
gateway 2605:6400:120::1

#以下是第三个IPv6地址
auto eth0:1
iface eth0:1 inet6 static
address 2605:6400:0120:1b99::4
netmask 48
gateway 2605:6400:120::1

#以下是第四个IPv6地址
auto eth0:2
iface eth0:2 inet6 static
address 2605:6400:0120:1b99::5
netmask 48
gateway 2605:6400:120::1

Debian11修改内容如下:

 
iface ens3 inet6 static
      address 2604:9cc0:0000:1134:0000:0000:0000:0003/64
      gateway 2604:9cc0::1

iface ens3:0 inet6 static
      address 2604:9cc0:0000:1134:0000:0000:0000:0004/64
      gateway 2604:9cc0::1

iface ens3:1 inet6 static
      address 2604:9cc0:0000:1134:0000:0000:0000:0005/64
      gateway 2604:9cc0::1

二、重启网络、查看IP信息

 
  //重启网络服务
root@ubuntu:~# sudo systemctl restart networking.service
  //查看IP信息
root@ubuntu:~# ip -6 addr show ens3

发表评论