vbox虚拟机网络设置

主机:win7-64Bit,虚拟机:visualBox debian64Bit
vbox连接方式:Bridged Adapter 桥接模式, 混杂模式:允许虚拟机
进入debian /etc/network/interfaces 设置静态分配
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
auto eth0
#iface eth0 inet dhcp
#auto eth0
iface eth0 inet static
address 192.168.16.246    (和主机同网段即可)
gateway 192.168.16.254    (和主机一致)
netmask 255.255.255.0
broadcast 192.168.16.255

然后进/etc/resolv.conf 设置dns
domain mshome.net
search mshome.net
nameserver 8.8.8.8 (和主机一致)

配置好后需要重启网卡,命令:(测试时好像用第二种可以)
第一种:使用ifconfig
例如要重启eth0
ifconfig eth0 stop
ifconfig eth0 start
第二种:ifdown和ifup
ifdown eth0
ifup eth0
第三种:service重启
service network restart/stop/start
 另,查看某个网卡的数据流量的方法:
watch -n 1 "/sbin/ifconfig eth0 | grep bytes"

这样好像就能上网了。。。只是这个连接方式如果主机不能上网,两者是不能ping通的
对于自动获取ip和dns的主机,虚拟机就不知道怎么上网了。所以得自己设置。
 
安装好文件后记得释放光驱。

 ===========================================================

新版的mint或debian7.8下上面的方法好像不行。静态ip生效后只保留下面的重启才ok。(应该和路由设置有关系,原本可以上网的debian7.5后来也不行,本地连接也不用开启共享连接)

auto lo

iface lo inet loopback 
这样能住宿互通,住宿都能联网。

修改BIOS的默认设置来解决在虚拟环境下对64位系统的支持:
选择Security----System Security--- Virtualization Technology(VTx)和 Virtualization Technology Directed I/O(VTd)后的Disable改成Enable。

================================================================================================================

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
# auto lo
# iface lo inet loopback

# The primary network interface
# auto enp0s3
# iface enp0s3 inet dhcp
##########################Ubuntu 16.04.4 LTS###################################

auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
address 192.168.120.246
netmask 255.255.255.0
gateway 192.168.120.1
重启网络即可sudo /etc/init.d/networking restart

=========================Ubuntu 18.04.4 LTS===========================
vbox网卡1设为 桥接网络 网卡2设为 网络地址转换NAT
xiao@ubuntu:~$ cat /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
addresses: [192.168.120.246/24]
#gateway4: 192.168.120.1
#nameservers:
# addresses: [192.168.40.190]
dhcp4: no
enp0s8:
dhcp4: yes

然后 netplan apply 不能加gateway4和nameservers 不明原因连不上外网

=============设置virtualbox共享文件夹==== http://download.virtualbox.org/virtualbox/
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom #将VBoxGuestAdditions.iso光驱挂接
cd /mnt/cdrom
./VBoxLinuxAdditions.run #确定没有failed
reboot

share是win下的共享文件夹 shared是linux下的
sudo mount -t vboxsf share /mnt/shared #挂载共享文件
sudo umount -f /mnt/shared #卸载共享文件

posted @ 2013-11-12 16:13  xiao913  阅读(2416)  评论(0编辑  收藏  举报