虚拟接口获取静态 IP,实际接口没有?

虚拟接口获取静态 IP,实际接口没有?

我有一台运行 Debian 6 的服务器,分配了两个静态 IP 地址:eth0 和 eth0:1(eth0 的虚拟接口)。启动时,两个地址都应该获得分配的 IP...但 eth0 没有。

/etc/network/interfaces

iface eth0 inet static
    address 192.168.9.171
    netmask 255.255.255.0
    network 192.168.9.0
    broadcast 192.168.9.255
    gateway 192.168.9.23
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 192.168.9.23 192.168.9.41
    dns-search ourdomain.local
auto eth0:1

iface eth0:1 inet static address 192.168.9.11 netmask 255.255.255.0 network 192.168.9.0 broadcast 192.168.9.255 gateway 192.168.9.23 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 192.168.9.23 192.168.9.41 dns-search ourdomain.local

ifconfig

eth0      Link encap:Ethernet  HWaddr 00:12:79:95:a4:e7
          inet6 addr: fe80::212:79ff:fe95:a4e7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10378 errors:0 dropped:8 overruns:0 frame:0
          TX packets:2256 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1634657 (1.5 MiB)  TX bytes:453396 (442.7 KiB)
          Interrupt:17

eth0:1    Link encap:Ethernet  HWaddr 00:12:79:95:a4:e7
          inet addr:192.168.9.11  Bcast:192.168.9.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:17

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:550 errors:0 dropped:0 overruns:0 frame:0
          TX packets:550 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:189714 (185.2 KiB)  TX bytes:189714 (185.2 KiB)

有什么想法吗?只有我这样做,它才能获得 IP ifconfig eth0 192.168.9.171

答案1

这是你的问题,默认情况下 debian 自带:allow-hotplug eth0

在这里查看官方文档: http://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_basic_syntax_of_etc_network_interfaces

相关内容