首页 > virtualbox中新建centos的VM,host无法访问vhost的网址

virtualbox中新建centos的VM,host无法访问vhost的网址

重点和不理解的地方在于虚拟机和主机之间的网络配置方案

基础信息

  1. VM环境
    系统

[adolph@localhost ~]$ cat /etc/redhat-release 
CentOS Linux release 7.0.1406 (Core)

网络配置

[adolph@localhost ~]$ ifconfig
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.105  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::a00:27ff:fe47:e46a  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:47:e4:6a  txqueuelen 1000  (Ethernet)
        RX packets 89705  bytes 129580766 (123.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 74851  bytes 6144471 (5.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 11558  bytes 998969 (975.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11558  bytes 998969 (975.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2.主机环境

adolph@geek:vm-install$ uname -a
Linux geek 3.13.0-64-generic #104-Ubuntu SMP Wed Sep 9 12:36:12 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  1. vm与主机间的网络方案

只用了网卡2的桥接方式,其它方式都没用

问题描述

我结合mesosphere advanced course上的教程一步一步做的。唯一不同的是官方教程用了Vagrant,在Vagrantfile中配置的网络是这样的

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "bento/centos-7.1"

  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.hostname = "node1"
end

使用private_network模式

我安装好了mesos,并启动了mesos的master和slave,并且启动了

[adolph@localhost ~]$ sudo netstat -nlp|grep mesos
[sudo] password for adolph: 
tcp        0      0 0.0.0.0:5050            0.0.0.0:*               LISTEN      1205/mesos-master   
tcp        0      0 0.0.0.0:5051            0.0.0.0:*               LISTEN      1206/mesos-slave 

我的VM桥接的IP是192.168.1.105,但是当我在host的浏览器中输入192.168.1.105:5050时,无法显示网页

个人分析

1.VM和host之间能相互ping通
2.vm中mesos的两个地址是0.0.0.0:50500.0.0.0:5051

希望大家帮忙看看问题出在哪里。这是配置


问题解决了。
配置是没问题的,关键在于要关掉CentOS的防火墙

centos 7:
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
之前的版本:
service iptables stop #停止
chkconfig iptables off #禁用

参考链接

参考-1

【热门文章】
【热门文章】