virtualbox版本5.2.10 r122406        centos版本6.5_x64

最近在配置本地虚拟机环境,之前纠结于NAT模式可以连外网,Host-Only模式只能连宿主机,配置环境的时候来回切比较烦。本来打算走网络共享路线来实现Host-Only模式下连接外网的,但是没有成功。问度娘半天终于实现NAT+Host-Only的方式联网

1、设置全局网络

管理

VirtualBox + CentOS 使用 NAT + Host-Only 方式联外网

网络CIDR设置为192.168.100.0/24

2、配置虚拟机网卡

VirtualBox + CentOS 使用 NAT + Host-Only 方式联外网

3、编辑virtualBox中的Host-Only网卡

VirtualBox + CentOS 使用 NAT + Host-Only 方式联外网

VirtualBox + CentOS 使用 NAT + Host-Only 方式联外网

4、为虚拟机设置两块网卡

VirtualBox + CentOS 使用 NAT + Host-Only 方式联外网

VirtualBox + CentOS 使用 NAT + Host-Only 方式联外网

网卡一为NAT连接,网卡二为Host-Only连接

5、启动虚拟机

cd /etc/sysconfig/network-scripts/

cp ifcfg-eth0  ifcfg-eth1

vim ifcfg-eth1

VirtualBox + CentOS 使用 NAT + Host-Only 方式联外网

删除【HWADDR】行,删除【UUID】行,添加【IPADDR】和【NETMASK】,修改【DEVICE】为【eth1】,【BOOTPROTO】为【static】:

设置该虚拟网卡的ip和网关

重启网卡

service network restart

ping www.baidu.com就可以ping通了,本地SSH连接192.168.56.103:22


参考:https://www.cnblogs.com/dee0912/p/5470700.html


相关文章:

  • 2021-11-19
  • 2021-10-26
  • 2021-05-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-10
  • 2022-03-02
  • 2021-10-04
  • 2022-12-23
  • 2021-11-03
  • 2022-01-21
相关资源
相似解决方案