我的服务器是专用的(非虚拟的)。我想要 3+1 个静态 IP。我以前使用过别名 (eth0:0, eth0:1),但读到此方法已被弃用。因此,我添加了另一个 IP,并在 i 时使用 ifup/ifdown 重新配置了我的接口;但是 ifdown 告诉我该接口未配置。
/etc/network/interfaces 看起来像这样:
auto lo eth0
iface lo inet loopback
# Main IPs (IPv4 + IPv6)
allow-hotplug eth0
iface eth0 inet static
address 81.x.x.x
netmask 255.255.255.0
broadcast 81.x.x.255
gateway 81.x.x.1
iface eth0 inet6 static
address 2a02:x:x:x::x:x
netmask 64
gateway 2a02:x:x:x::1
# 2nd IP
up ip addr add 81.x.x.x/32 dev eth0
# 3rd IP
up ip addr add 81.x.x.x/32 dev eth0
Run Code Online (Sandbox Code Playgroud)
请注意,第二个和第三个 IP 地址来自不同的网络范围(不知道是否重要)
我重新加载网络配置
nohup sh -c "ifdown …
Run Code Online (Sandbox Code Playgroud)