由于centos6上的docker版本只能到1.7.1,为了使用高版本的docker,虚拟机的系统版本需要更新到centos7。我采用的是vmware安装vm,iso文件为http://mirror.neu.edu.cn/centos/7/isos/x86_64/下的CentOS-7-x86_64-Minimal-1611.iso。
网络的要求是:
1、虚拟机能访问外网
2、宿主机能访问到虚拟机
下面是网络配置过程的记录:
1、使用systemctl status network查看服务状态,得到如下错误信息、
hdcoe02 network[597]: Bringing up interface enp0s25: Error: Connection activation failed: Connection 'enp0s25' is not available on the device enp0s25 at this time.
hdcoe02 network[597]: [FAILED]
hdcoe02 systemd[1]: network.service: control process exited, code=exited status=1
hdcoe02 systemd[1]: Failed to start LSB: Bring up/down networking.
hdcoe02 systemd[1]: Unit network.service entered failed state.
解决方法:
设定开机启动一个名为NetworkManager-wait-online服务,命令为:
systemctl enable NetworkManager-wait-online.service
2、CentOS7中已经取消了ifconfig,用nmcli进行了代替
具体配置方法可参考:
http://blog.csdn.net/cmzsteven/article/details/49777667
https://my.oschina.net/ihanfeng/blog/601853
3、到此为止虚拟机可以正常访问外网,但宿主机上不能访问虚拟机
发现broadcast是192.168.83.150,需要改成下图的192.168.83.255
解决方法:
CentOS 7支持使用PREFIX以长度方式指明子网掩码;之前的PREFIX是32,所以brd跟ip是一样的,将PREFIX改成24就可以。
最终的ifcfg-ens33配置文件如下,重点的项红框标出: