虚拟机连网是头等大事,所以我们先解决这个问题。通过桥接可以实现联网,主要用到的命令有:brctl,ifconfig,tunctl,route
brctl是一个以太网桥接工具,常见的用法有:
如果发现无法删除网桥,那么可能是还没有将其关闭:
yao@twomoon:~$ sudo brctl delbr br0
bridge br0 is still up; can't delete it
yao@twomoon:~$ sudo ifconfig br0 down
yao@twomoon:~$ sudo brctl delbr br0
说了这么多,到这才是重点。首先,将物理网卡桥接:
yao@twomoon:~$ ifconfig -a |grep eth
eth0 Link encap:Ethernet HWaddr 90:fb:a6:14:cd:42
yao@twomoon:~$ brctl addbr br0
yao@twomoon:~$ brctl addif br0 eth0
yao@twomoon:~$ ifconfig eth0 0.0.0.0
yao@twomoon:~$ ifconfig br0 192.168.1.51 up
这样又多了一个网络设备br0:
yao@twomoon:~$ LANG=C ifconfig -a |grep Ethernet