VPS的默认的网络配置
默认的网络配置文件通常位于 /etc/network/interfaces.d/50-cloud-init。下面是一个双IPv6和IPv4配置的示例:
# 回环接口配置
auto lo
iface lo inet loopback
dns-nameservers 2606:4700:4700::1111 2001:4860:4860::8888
# IPv4基础配置
auto eth0
iface eth0 inet static
address x.x.x.x/24
dns-nameservers 2606:4700:4700::1111 2001:4860:4860::8888
gateway x.x.x.1
dns {'nameservers': ['2606:4700:4700::1111', '2001:4860:4860::8888'], 'search': []}
# 主IPv6配置
iface eth0 inet6 static
address xxxx:xxxx:xxx:xxxx:xxxx:xxxx:xx:x/128
gateway xxxx:xxxx:xxx::1
# 次要IPv6配置
iface eth0 inet6 static
address xxxx:xxx:xxx:xxx::xxxx:x/128
修改后VPS的网络配置(建议先备份文件再操作)
# 回环接口配置
auto lo
iface lo inet loopback
dns-nameservers 2606:4700:4700::1111 2001:4860:4860::8888
# IPv4基础配置
auto eth0
iface eth0 inet static
address x.x.x.x/24
dns-nameservers 2606:4700:4700::1111 2001:4860:4860::8888
gateway x.x.x.1
dns {'nameservers': ['2606:4700:4700::1111', '2001:4860:4860::8888'], 'search': []}
# 主IPv6(出口)配置
iface eth0 inet6 static
address xxxx:xxxx:xxx:xxxx:xxxx:xxxx:xx:x/128
gateway xxxx:xxxx:xxx::1
# 次要IPv6(入口)配置 - 使用别名接口
auto eth0:1
iface eth0:1 inet6 static
address xxxx:xxx:xxx:xxx::xxxx:1/128
iface eth0:1 inet6 static
address xxxx:xxx:xxx:xxx::xxxx:2/128
iface eth0:1 inet6 static
address xxxx:xxx:xxx:xxx::xxxx:3/128(以此类推)
配置说明
出口IP:配置在主接口 eth0,用于出站流量。
入口IP:配置在别名接口 eth0:1,专用于接收入站流量。
IPv4同理,以上仅展示IPv6
修改完后重启Reboot