我在virtualbox中使用下面给定的Vagrantfile设置配置了vagrant。我可以从主机(HM)连接到在虚拟机上运行的web服务器。
我也可以从网络机器ping到服务器,但当我尝试从网络访问web服务器时,虚拟机(VM)收到请求并表示响应(apache),但网络机器(NM)没有得到响应。
如何配置vagrant或virtualbox从NM访问?我尝试在虚拟机接口文件中将eth1更改为eth0,但不起作用。流浪汉开不动机器。
提前感谢
Vagrantfile:
config.vm.define "web" do |web|
web.vm.box = "raring"
web.vm.network "public_network", ip: "192.168.0.53", bridge: 'eth0'
web.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--memory", 1024]
end
end主机接口
eth0 Link encap:Ethernet HWaddr 54:04:a6:68:7d:85
inet addr:192.168.0.102 Bcast:255.255.255.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:576 Metric:1
RX packets:142100 errors:0 dropped:0 overruns:0 frame:0
TX packets:110704 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:61653460 (61.6 MB) TX bytes:14976111 (14.9 MB)
Interrupt:55 Base address:0xa000 虚拟机接口
eth0 Link encap:Ethernet HWaddr 08:00:27:49:4c:f1
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe49:4cf1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:386 errors:0 dropped:0 overruns:0 frame:0
TX packets:276 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:41117 (41.1 KB) TX bytes:36296 (36.2 KB)
eth1 Link encap:Ethernet HWaddr 08:00:27:c3:16:90
inet addr:192.168.0.53 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fec3:1690/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:946 errors:0 dropped:0 overruns:0 frame:0
TX packets:1017 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:116117 (116.1 KB) TX bytes:90515 (90.5 KB)虚拟机/etc/network/interface文件:
# The primary network interface
auto eth0
iface eth0 inet dhcp
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto eth1
iface eth1 inet static
address 192.168.0.53
netmask 255.255.255.0
#VAGRANT-END虚拟机上的apache响应:
192.168.0.100 - - [16/Nov/2013:10:39:10 +0000] "GET / HTTP/1.1" "curl/7.32.0" 200 7466 6005发布于 2015-03-08 05:51:34
这个问题不是由漫游或漫游设置引起的,而是因为虚拟机(VM)中的apache配置错误。
在虚拟机中修改您的apache站点配置:
vim /etc/apache2/sites-enabled/yours_site_config.conf
将服务器名称更改为:ServerName 192.168.0.53
重新启动apache后,在浏览器中检查结果。
例如:
<VirtualHost *:80> ServerAdmin servers@localhost ServerName 192.168.0.53 DocumentRoot /var/www </VirtualHost>
192.168.0.53 -这是您的虚拟机的inet地址。
https://stackoverflow.com/questions/20017658
复制相似问题