Linux
虛擬介面獲取靜態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
。
那是你的問題,debian 預設自帶:allow-hotplug eth0
在此處查看官方文件:http: //www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_basic_syntax_of_etc_network_interfaces