cloudcone默认给了3个IPv6,但默认只启用了1个,这里设置全部启用,此方法也适用于拥有IPv6/64的机器比如WAWO的IPv6机
系统默认为debian系,演示使用的是debian11:
1: vi /etc/network/interfaces 或者不会使用vi编辑命令就使用finalshell打开并编辑文件interfaces
默认的格式为:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 55.55.12.55
netmask 255.255.255.128
gateway 55.55.55.129
iface eth0 inet6 static
accept_ra 0
address 你的IPv6-1
netmask 64
gateway 8888:8888:0000:8888::1
up /sbin/ifconfig eth0 inet6 add 3333:33333:0000:3333:0000:0000:2222:f075/64
up /sbin/ifconfig eth0 inet6 add 22222:2222:0000:3333:0000:0000:2222:c845/64
可以看到默认只启用了一个IPv6,
根据格式修改为:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 55.55.12.55
netmask 255.255.255.128
gateway 55.55.55.129
iface eth0 inet6 static
accept_ra 0
address 你的IPv6-1
netmask 64
gateway 1111:1111:0000:1111::1
iface eth0 inet6 static
accept_ra 0
address 你的IPv6-2
netmask 64
gateway 1111:5555:0000:1111::1
iface eth0 inet6 static
accept_ra 0
address 你的IPv6-3
netmask 64
gateway 1111:1111:0000:1111::1
保存并退出后 systemctl restart networking.service 重启网络,等待几秒后即可使用
如果是拥有IPv6/64的机器
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.10.33.147/22
dns-nameservers 1.1.1.1 8.8.8.8 2221:4220:4860::8888 20221:4220:4220::8844
gateway 10.10.32.1
# control-alias eth0
iface eth0 inet6 static
address 你的IPV6::a/64
gateway 2333:c333:26::1那么根据格式:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.10.33.147/22
dns-nameservers 1.1.1.1 8.8.8.8 2221:4220:4860::8888 20221:4220:4220::8844
gateway 10.10.32.1
# control-alias eth0
iface eth0 inet6 static
address 你的IPV6::a/64
gateway 2333:c333:26::1
iface eth0 inet6 static
address 你的IPV6::b/64
gateway 2333:c333:26::1
iface eth0 inet6 static
address 你的IPV6::c/64
gateway 2333:c333:26::1
以此类推,根据需要添加多少个
保存并退出后 systemctl restart networking.service 重启网络,等待几秒后即可使用
参考文档:
Ubuntu 配置文件:/etc/netplan
服务器上配置网卡和IPv6地址:https://www.laoxu.cc/post/109.html
评论 (0)