如何使用IPv6/64段内任意一个IPv6地址而非默认地址
来自md5.pw
更多语言
更多操作
概述
本教程介绍如何在搬瓦工的 Linux 系统中通过配置虚拟网卡(v4tunnel),从分配的 IPv6 /64 段中自由指定并使用任意一个 IPv6 地址。
操作步骤
1. 清理现有网络设备
在开始配置前,先尝试关闭并删除可能冲突的旧设备:
ifdown ipv6net 2>/dev/null
ip link delete ipv6net 2>/dev/null2. 修改网络配置文件
编辑网络配置文件 /etc/network/interfaces,添加以下配置段。
nano /etc/network/interfacesauto ipv6net
iface ipv6net inet6 v4tunnel
#输入你要指定的IPv6地址
address 2607:8700:5501:xxxx:xxxx:xxxx:xxxx:xxxx
netmask 64
endpoint 207.246.106.118
#输入IPv4地址
local xxx.xxx.xxx.xxx
ttl 255
gateway 2607:8700:5501:xxxx::1
mtu 14803. 启用并验证
执行以下命令启用网卡并检查状态:
# 启动接口
ifup ipv6net
# 查看接口状态
ip link show ipv6net
# 验证 IPv6
curl -6 ifconfig.me4. 关闭IPv6地址自动配置
systemctl stop ipv6net.service
systemctl disable ipv6net.service注意事项
VPS在进行迁移或快照恢复的时候, 会重置ipv6net, 需要重新按照此教程进行配置