我使用下面给定的Vagrantfile设置为virtualbox配置了vagrant。我可以从主机(HM)连接到虚拟机上运行的Web服务器。
我也可以从网络机器ping服务器,但是当我尝试从网络访问Web服务器时,虚拟机(VM)获取请求并说它响应(apache),但网络机器(NM) )没有得到回复。
我应该如何配置要从NM访问的vagrant或virtualbox?我尝试在VM接口文件上将eth1更改为eth0,但它没有用。 Vagrant无法放松机器。
提前致谢
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 / interfaces文件:
# 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
答案 0 :(得分:0)
此问题不是来自流浪汉或流浪汉设置,而是因为虚拟机(VM)中的错误apache配置。
在VM中修改您的apache站点配置:
vim /etc/apache2/sites-enabled/yours_site_config.conf
将服务器名称更改为:ServerName 192.168.0.53
重启apache后,请在浏览器中查看结果。
E.g:
<VirtualHost *:80>
ServerAdmin servers@localhost
ServerName 192.168.0.53
DocumentRoot /var/www
</VirtualHost>
192.168.0.53 - 这是你的虚拟机的补充。