下载Mininet虚拟机镜像,Virtual box 中设置NAT访问外网,Host-Only与宿主机通信。启动虚拟机后网络配置如下,没有识别NAT网卡和HostOnly网卡。
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:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:896 (896.0 B) TX bytes:896 (896.0 B)
修改interfaces文件如下
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp auto eth1 iface eth1 inet static address 192.168.56.99 netmask 255.255.255.0 gateway 192.168.56.1 nameserver 127.0.0.1
重起networking后提示没有eth0和eth1.查找各种原因后测试ifconfig -a发现网卡明明不是eth0和eth1而是eth12和eth13.修改该interface如下:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth12 iface eth12 inet dhcp auto eth13 iface eth13 inet static address 192.168.56.99 netmask 255.255.255.0 gateway 192.168.56.1 nameserver 127.0.0.1
重启。网卡配置正确。
此问题可能存在于各种虚拟化软件中。OpenStack虚拟机网卡错误可能也是这个原因。