1. 查看编辑网卡
    sudo vim /etc/network/interfaces  或

     sudo vi /etc/network/interfaces


2. 按 I 开始编辑(添加IP不需要再次输入网关和DNS,只需要输入IP,子网)

比如这是原始的网卡IP

auto eth0
iface eth0 inet static  
    address 192.168.2.155  
    netmask 255.255.255.0  
    gateway 192.168.2.1  
    dns-nameservers 218.85.157.99 218.85.152.99 
 
 3.现在添加第二个IP

auto eth0:0
iface eth0:0 inet static  
    address 192.168.2.156 
    netmask 255.255.255.0  


4.接着就是保存了,按Esc退出,输入 : wq 在输入shift+! 然后回车

 

5. 重启网卡网络服务

sudo /etc/init.d/networking restart