在Debian 6.0.4中的静态虚拟IP

Debian 6.0.4我的静态IP是192.168.1.151,我想添加一个IP 192.168.1.175作为虚拟IP。 因为我在/ etc / networking / interfaces中做了以下更改

  #此文件描述您的系统上可用的networking接口
 #以及如何激活它们。 有关更多信息,请参阅接口(5)。

 #环回networking接口
汽车
 iface lo inet loopback

 #主要networking接口
 allow-hotplug eth0
 #NetworkManager#iface eth0 inet dhcp

 auto eth0

     iface eth0 inet static
        地址192.168.1.151
        网关192.168.1.1
        networking掩码255.255.255.0
        networking192.168.1.0
        广播192.168.1.255

 auto eth0:0
     iface eth0:0 inet static
        地址192.168.1.175
        networking掩码255.255.255.0
        广播192.168.1.255
        网关192.168.1.1 

当我运行命令

  / sbin / ifconfig -a 

我得到以下信息

  eth0 Link encap:Ethernet HWaddr 44:87:fc:eb:b2:50  
           inet addr:192.168.1.151 Bcast:192.168.1.255 Mask:255.255.255.0
           inet6地址:fe80 :: 4687:fcff:feeb:b250 / 64范围:链接
          广播运行多播MTU:1500公制:1
           RX数据包:338433错误:0丢弃:0超出:0帧:0
           TX数据包:238153错误:0丢弃:0超限:0载波:0
          碰撞:0 txqueuelen:1000 
           RX字节:337480876(321.8 MiB)TX字节:68577550(65.4 MiB)
          中断:25 

链路封装:本地环回  
           inet addr:127.0.0.1掩码:255.0.0.0
           inet6 addr::: 1/128范围:主机
           UP LOOPBACK RUNNING MTU:16436公制:1
           RX数据包:3735错误:0丢弃:0超出:0帧:0
           TX数据包:3735错误:0丢弃:0超载:0载波:0
          碰撞:0 txqueuelen:0 
           RX字节:494269(482.6 KiB)TX字节:494269(482.6 KiB)

 pan0链接封装:以太网HWaddr 16:56:67:bf:36:84  
           BROADCAST MULTICAST MTU:1500公制:1
           RX包:0个错误:0个丢弃:0个超限:0个帧:0个
           TX数据包:0错误:0丢弃:0超载:0载波:0
          碰撞:0 txqueuelen:0 
           RX字节:0(0.0 B)TX字节:0(0.0 B) 

大多数情况下,我得到这个,但有一段时间,我得到的输出虚拟IP。 我必须使虚拟IP永久。 我怎样才能做到这一点? 我也将这个虚拟IP(192.168.1.175)分配给两台机器。

谢谢

别名/虚拟接口已弃用,不应使用。 你应该使用iproute2来添加额外的地址到实际的接口:

iface eth0 inet static address 192.168.1.151 gateway 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 up ip addr add 192.168.1.175/24 dev eth0 

要检查configuration的IP地址,请使用ip addr show

分配相同的IP到多台机器将导致既不能正常工作。