给LunixVPS添加多个IP

如果你的Debian/Ubuntu 服务器/VPS 可以申请到新IP,但又没有自动添加上去,需要你手动添加,可以看这里。

编辑 /etc/network/interfaces 添加上你的新IP。假设你原有IP为11.11.11.11,需要添加 22.22.22.22 和 33.33.33.33 IP,按以下样例修改:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 11.11.11.11
netmask 255.255.254.0
gateway 11.11.11.1
auto eth0:0
iface eth0:0 inet static
address 22.22.22.22
netmask 255.255.254.0

auto eth0:1
iface eth0:1 inet static
address 33.33.33.33
netmask 255.255.254.0

dns-nameservers 8.8.8.8 8.8.4.4

Note: 网关不用修改,也只需要原来的那一组,需要添加 eth0:0 , eth0:1 , eth0:X 一直下去。修改之后,用命令 /etc/init.d/networking restart 重启网络。

但这样新IP还不能用,还需要将新IP上线,命令: ifup eth0:0
有多个IP,就 ifup eth0:1 , ifup eth0:2 , ifup eth0:3 … 都上线。
Note: 对应的下线命令是 ifdown eth0:X (X改成对应的数字,这里就不重复了)

转自 简书

Leave a Reply

Your email address will not be published. Required fields are marked *