Tam*_*ara 16 virtualbox virtual-machine vagrant
我有安装了vagrant的Mac OS.在客机上我有Ubuntu 12.所以,我想做的是从主机ping客户机.
连接到NAT的来宾机(根据VirtualBox设置)
我在客机上找到了一个接口(lo除外):
eth0 Link encap:Ethernet HWaddr 08:00:27:88:0c:a6
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe88:ca6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:581 errors:0 dropped:0 overruns:0 frame:0
TX packets:410 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:61376 (61.3 KB) TX bytes:51599 (51.5 KB)
Run Code Online (Sandbox Code Playgroud)
问题是主机上的10.0.2.*网络中没有IP地址.主机有几个vboxnet接口,但它们都没有任何ip地址:
vboxnet0: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00
vboxnet1: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:01
vboxnet2: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:02
vboxnet3: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:03
Run Code Online (Sandbox Code Playgroud)
您是否知道为什么VirtualBox没有将ip地址分配给主机?我能做些什么才能ping阵风?
这是我的流浪文件(我删除了一些我不使用的注释行):
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "hashicorp/precise64"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
# config.vm.box_url = "http://domain.com/path/to/above.box"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 3306, host: 8086
config.vm.network "forwarded_port", guest: 27017, host: 27017
config.vm.synced_folder "/Users/KoulSlou/Documents/Cloudware12.10", "/vagrant", owner: "www-data", group: "www-data"
config.vm.synced_folder "/Users/KoulSlou/Documents/Cloudware/public","/cloudware", owner: "www-data", group: "www-data"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
#config.vm.network "private_network", ip: "192.168.1.2"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true
...
end
Run Code Online (Sandbox Code Playgroud)
m1k*_*eil 26
默认情况下(即,当不接触任何网络配置时),Vagrant在VirtualBox中配置VM以将其第一个接口(eth0)附加到" NAT "(不要将其与" NAT网络 " 混淆,后者是VirtualBox中的不同选项).
当您的VM接口连接到NAT时,guest虚拟机将获得10.0.2.15 IP.在主机端,您只能看到没有IP的vboxnet #interface.您可以将此接口视为该guest虚拟机的专用路由器.
连接到NAT的VM不可从外部路由.这是设计上的,这也是vboxnet #interface没有IP的原因之一.虚拟机能够访问"外部世界",例如互联网和主机,但无法在没有端口转发的情况下从外部访问.
如果默认行为不是您要查找的,Vagrant提供网络配置的高级抽象:
每个配置都有它自己的优点和缺点,这实际上取决于你计划实现的目标.有关其他信息,请查看VirtualBox关于网络的文档.
Wya*_*ett -1
我不确定为什么您在来宾上看到 IP 地址,但鉴于该 vagrant 文件,您根本没有配置任何 virtualbox 网络。您需要取消注释该config.vm.network "private network"行,然后配置 IP 地址。
virtualbox 的默认设置是将主机置于 10.0.0.2 并将整个 10.0.0.0/8 范围公开为本地地址,因此我认为 10.xxx 范围内的任何内容都适用于客户端虚拟机。