Skip to content

ubuntu上添加多个ip

最近入了个某俄厂的vps,这个vps可以提供多个ip,2欧每个,对目前手上的一个靠ip来收费的项目来说会降低不少成本。

那怎么添加新增的ip呢?在原先的网卡配置上加个配置就好了

vi /etc/network/interfaces

原先的配置如下

auto ens3
iface ens3 inet static
    address 原有ipv4地址/24
    gateway x.x.x.x
    # dns-* options are implemented by the resolvconf package, if installed
   dns-nameservers 8.8.8.8 8.8.4.4
   dns-search xxx.com


在该配置文件末尾加上配置

auto ens3:0
iface ens3:0 inet static
    address 新增ipv4地址
    netmask 255.255.255.255

ens3是我这个vps的网卡,其他机器可能是eth0之类的,不同机器不一样。

如果还有其他ip就再添加配置,如ens3:1,增加ens3:n这里的序号即可。

注意:此处配置是使用的ubuntu系统,如果其他linux版本,如centos,配置可能不同。

配好后,启用网卡

ifup ens3:0

此时ping下新的ip地址,应该就ok了。

OVER!

Published in自建服务

Be First to Comment

Leave a Reply

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