我必须分配给 VM(ubuntu 14.04,使用 virt-manager 安装在虚拟环境中)。在 virt-manager 上我已经创建了 2 个这样的 vnetwork
这是分配了 2 个 vnet 的 VM
而接口文件是这样配置的
sudo nano /etc/network/interfaces
# The PUBLIC first network interface
auto eth0
iface eth0 inet static
address 1.1.1.254
netmask 255.255.255.0
network 1.1.1.0
broadcast 1.1.1.255
gateway 1.1.1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 1.1.1.1
# The PRIVATE second network interface
auto eth1
iface eth0 inet static
address 1.1.10.254
netmask 255.255.255.0
network 1.1.10.0
broadcast 1.1.10.255
gateway 1.1.10.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 1.1.10.1
而命令 ifconfig -a 显示了所有界面
eth0 Link encap:Ethernet HWaddr 52:54:00:36:50:3d
inet addr:1.1.1.254 Bcast:1.1.1.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe36:503d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:765 errors:0 dropped:3 overruns:0 frame:0
TX packets:716 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:240028 (240.0 KB) TX bytes:242849 (242.8 KB)
eth1 Link encap:Ethernet HWaddr 52:54:00:9c:81:b5
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
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:65536 Metric:1
RX packets:22278 errors:0 dropped:0 overruns:0 frame:0
TX packets:22278 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7130945 (7.1 MB) TX bytes:7130945 (7.1 MB)
virbr0 Link encap:Ethernet HWaddr fe:3c:72:75:26:f8
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
我还运行了 lshw -c network,界面结果为 disable
*-network:0
description: Ethernet interface
product: Virtio network device
vendor: Red Hat, Inc
physical id: 3
bus info: pci@0000:00:03.0
logical name: eth0
version: 00
serial: 52:54:00:36:50:3d
width: 32 bits
clock: 33MHz
capabilities: msix bus_master cap_list rom ethernet physical
configuration: broadcast=yes driver=virtio_net driverversion=1.0.0 ip=1.1.1.254 latency=0 link=yes multicast=yes
resources: irq:11 ioport:c020(size=32) memory:fc096000-fc096fff memory:fc000000-fc03ffff
*-network:1 DISABLED
description: Ethernet interface
product: Virtio network device
vendor: Red Hat, Inc
physical id: 4
bus info: pci@0000:00:04.0
logical name: eth1
version: 00
serial: 52:54:00:9c:81:b5
width: 32 bits
clock: 33MHz
capabilities: msix bus_master cap_list rom ethernet physical
configuration: broadcast=yes driver=virtio_net driverversion=1.0.0 latency=0 link=no multicast=yes
resources: irq:11 ioport:c040(size=32) memory:fc097000-fc097fff memory:fc040000-fc07ffff
为什么 eth1 接口没有通过文件接收 IP 地址,而手动是?
哎呀,我太不专心了……这是错误
我错了 iface