VirtualBox网络配置使用案例
VirtualBox
VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL) version 2. See "About VirtualBox" for an introduction.
Presently, VirtualBox runs on Windows, Linux, Macintosh, and Solaris hosts and supports a large number of guest operating systems including but not limited to Windows (NT 4.0, 2000, XP, Server 2003, Vista, Windows 7, Windows 8, Windows 10), DOS/Windows 3.x, Linux (2.4, 2.6, 3.x and 4.x), Solaris and OpenSolaris, OS/2, and OpenBSD.
VirtualBox is being actively developed with frequent releases and has an ever growing list of features, supported guest operating systems and platforms it runs on. VirtualBox is a community effort backed by a dedicated company: everyone is encouraged to contribute while Oracle ensures the product always meets professional quality criteria.
诸多新技术的出现,善于折腾个的伙伴总是想方设法的搭建出来一个环境来尝鲜。譬如:openstack,k8s,opendaylight等等环境的搭建均需要用到多台虚机。为了能够兼容快捷和成本的特性,VirtualBox则提供出了一种不错的方式来解决该问题。
VirtualBox安装时顺带安装了一块虚拟网卡[VirtualBox Host-Only Network]
1.关于该虚拟网卡:
以太网适配器 VirtualBox Host-Only Network:
连接特定的 DNS 后缀 . . . . . . . :
本地链接 IPv6 地址. . . . . . . . : fe80::f561:c34e:2a2:5f97%15
IPv4 地址 . . . . . . . . . . . . : 192.168.56.1
子网掩码 . . . . . . . . . . . . : 255.255.255.0
默认网关. . . . . . . . . . . . . : 该网卡实际上实现了一个虚拟的二层交换机。所以,为了能使我们能够ssh到虚机中,可以给该虚机添加一块host-only的网卡: 这样当系统装好以后,系统就会分配到一个192.168.56.xx/24的地址,这时候,我们就可以在本地通过192.168.56.0/24这个网段ssh到虚拟。如果为了使地址重启不会变化,我们可以在相对应的网卡文件中做配置。具体的配置目录为:
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
如果对应的网卡文件不存在就手工编辑一个。【编辑的标准是以ifconfig查看出来的结果为准】
比如:
[root@localhost network-scripts]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:54:26:9b:3e txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:feac:a051 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:ac:a0:51 txqueuelen 1000 (Ethernet)
RX packets 1 bytes 590 (590.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9 bytes 990 (990.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.56.2 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::8f94:43c1:2fa6:d3c9 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:37:81:93 txqueuelen 1000 (Ethernet)
RX packets 106 bytes 12192 (11.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 106 bytes 19973 (19.5 KiB)
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 1 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost network-scripts]#
这里边有两块网卡: enp0s3和enp0s8。其中enp0s8为后手工添加。
该host-only的网卡解决了本地ssh到虚机的一种方案,但是多数情况下,虚机是有连接外网的需求,这时候可用桥接可用nat模式,首先这里推荐使用nat模式,关于桥接模式回随着外部的宿主机的网络的变化而变化,所以每次都需要修改,相当的不方便。而使用NAT模式,则可独立于宿主机的网络,从而实现连接外网的需求。
用于实现本地ssh网卡地址为:192.168.56.2
用于实现连接外网的网卡地址为:10.0.2.15
其中NAT网卡见:

总体的实现机制为:

Note:这样做的好处:
1.本地虚机之间的互联互通可通过192.168.56.0/24网段来实现,而该二层交换是在本地实现的,所以效率很高。
2.虚机连接外网用NAT网卡,这样不用去适配外部宿主机上的网络变化。
3.不用占用外部网络地址。
2.如有疑问
########################################################################
#Date:2018-03-012 Author:BurlyLuo#
#Mail:olaf.luo@foxmail.com Version:v1.0 #
######################################################################## 非商业用途转载无需作者授权,但务必在文章标题下面注明作者 罗伟(Burly Luo)以及可点击的本博客地址超级链接 http://www.cnblogs.com/BurlyLuo/,谢谢合作.
VirtualBox网络配置使用案例的更多相关文章
- 【Linux】VirtualBox网络配置桥接模式
VirtualBox网络配置桥接模式 CentOS/RHEL (虚拟机)配置 # 基于桥接模式设置固定 ip cat >> /etc/sysconfig/network-scripts/i ...
- VirtualBox网络配置
VirtualBox中有4中网络连接方式: NAT Bridged Adapter Internal Host-only Adapter VMWare中有三种,其实他跟VMWare 的网络连接方式都是 ...
- 【Linux】VMware及VirtualBox网络配置
在VMware或VirtualBox中,安装完linux系统,不能连到win7 具体配置,如下. 如上.
- virtualbox桥接网络配置--CentOS
系统安装好后如下图设置virtualbox虚拟机的网络连接方式 然后启动虚拟机 ifconfig发现如下图 vi /etc/sysconfig/network-scripts/ifcfg-eth0 根 ...
- virtualbox虚拟机上安装centOS的网络配置(安装centos时选择桥接网络)
最近接触hadoop,需要在在Linux上面开发,所以我装了一个virtualbox虚拟机,在该虚拟机上面安装了一个centOS系统.linux系统是装好了,但是网络配置却另人头疼.我主要是想让宿主机 ...
- Virtualbox的centos7 nat和桥接网络配置
在实际配置虚拟机的过程中,网络配置时候一个很繁琐的过程,经常一个点没注意到,就访问不了了.在此,做一个简单的教程以供后续使用时可以参考! 方法一: 使用NAT网络 1. 选择网卡 安装centos7的 ...
- VirtualBox安装CentOS7的网络配置
VirtualBox安装CentOS7的网络配置 这几天在本机VirtualBox安装CentOS时遇到了网络的坑... VirtualBox的下载地址:https://www.virtualbox. ...
- VirtualBox 文件共享及网络配置技巧
文件共享 1. 安装增强功能 2. 分配数据空间 这样就可以在virtualbox里访问本地的数据了: 网络配置
- VirtualBox虚拟机Centos7网络配置
Centos7要实现虚拟机可以链接网络,主机与虚拟机可以互相通过ip地址访问,需要配置两种网卡,两张网卡配置不同的网络链接方式 virtualBox 网络链接讲解地址:https://www.cnbl ...
随机推荐
- Flume - Kafka日志平台整合
1. Flume介绍 Flume是Cloudera提供的一个高可用的,高可靠的,分布式的海量日志采集.聚合和传输的系统,Flume支持在日志系统中定制各类数据发送方,用于收集数据:同时,Flume提供 ...
- IPFS家族(二)
go-ipfs IPFS协议的go语言实现,ipfs的核心协议,最新版是v0.4.13 下载地址:https://dist.ipfs.io/#go-ipfs 源代码地址:https://github. ...
- LNMP+FARM+DNS
LNMP 1.安装Nginx前的环境. # yum -y install gcc gcc-c++ pcre-devel zlib-devel openssl-devel 2.添加www系统用户,在 ...
- console.log(0.2+0.4===0.6)// true or false??
在正常的数学逻辑思维中,0.2+0.4===0.6这个逻辑是正确的,但是在JavaScript中0.2+0.4!==0.6这是为什么呢?这个问题也会偶尔被用来当做面试题来考查面试者对 JavaScri ...
- Vue解析五之mounted
在mounted获得vue的实例要加 this.$nextTick(function () { // 代码保证 this.$el 在 document 中 }) mounted: function ( ...
- 20个JS正则表达式
1 . 校验密码强度密码的强度必须是包含大小写字母和数字的组合,不能使用特殊字符,长度在8-10之间. ^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$ 2. 校验中文 ...
- 关于synchronized与volatile的小析
简单点说:synchronized很强大,既可以保证原子性,也可以保证可见性,而volatile不能保证原子性: 可见性:一个线程对共享变量值的修改,能够及时的被其它线程看到. 共享变量:如果一个变量 ...
- .NET Core快速入门教程 5、使用VS Code进行C#代码调试的技巧
一.前言 为什么要调试代码?通过调试可以让我们了解代码运行过程中的代码执行信息,比如变量的值等等.通常调试代码是为了方便我们发现代码中的bug.ken.io觉得熟练代码调试技巧是成为合格程序员的基本要 ...
- WebAPI问题追踪日志记录过滤器
公司项目比较坑爹,毕竟涉及到前后端分离.多部门协作,很多时候系统出问题,哪怕已经很清楚了,协作方依然要我们把API调用入参.响应等记录下来,而且是全记录,不光是异常调用,待调查结束后这些日志又需要卸下 ...
- IO流回顾与总结第一篇之字节流与字符流的操作。。。。。
一.引言 趁着年后的这点时间,抓紧点时间回顾下javase中的IO流,以往都是用到那些常用的IO类,这次来个全点的,有不对的地方还请大神指正一下,做到坚持写博的习惯来...... 回归正题,IO流顾名 ...