当前位置: 首页 > 操作系统 > Linux > 正文

ubuntu中如何添加新IP

时间:2014-10-02 iteye eimhee

vi /etc/network/interfaces

会显示如下:

Java代码

auto lo  
iface lo inet loopback  
      
auto eth0  
iface eth0 inet static
        address 207.210.118.56
        netmask 255.255.255.224
        broadcast 207.210.118.63
        network 207.210.118.32
        gateway 207.210.118.33

添加新行

Java代码

auto eth0:1

在这行下面

Java代码

auto eth0

添加新的interface信息

Java代码

iface eth0:1 inet static
        address 207.210.118.58
        netmask 255.255.255.224
        broadcast 207.210.118.63
        network 207.210.118.32
        gateway 207.210.118.33

检查MASK和网关是否正确

添加完毕, 会显示如下

Java代码

auto lo  
iface lo inet loopback  
      
auto eth0  
auto eth0:1
iface eth0 inet static
        address 207.210.118.56
        netmask 255.255.255.224
        broadcast 207.210.118.63
        network 207.210.118.32
        gateway 207.210.118.33
iface eth0:1 inet static
        address 207.210.118.58
        netmask 255.255.255.224
        broadcast 207.210.118.63
        network 207.210.118.32
        gateway 207.210.118.33

之后重启网络

/etc/init.d/networking restart

本文URL地址:http://www.bianceng.cn/OS/Linux/201410/45338.htm