概述:VirtualBox NAT host-only高级网络配置,虚拟机既可以相互通信也可以上网。同时,添加NAT方式让虚拟机上网,添加host-only方式让虚拟机与虚拟机通信。深入分析Host-only自定义网段,Windows和Linux环境下分别使用ssh,网卡命名规则。默认已经安装virtualbox,在virtualbox中已经安装ubunut系统。
sudo vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface(NAT)
auto enp0s3
iface enp0s3 inet dhcp
# 增加的Host-only静态IP设置 (enp0s8 是根据拓扑关系映射的网卡名称(旧规则是eth0,eth1))
# 可以通过 ```ls /sys/class/net```查看,是否为enp0s8
auto enp0s8
iface enp0s8 inet static
address 192.168.56.101
netmask 255.255.255.0
reboot
至此,完成虚拟机与虚拟机互通,虚拟机与主机互通,并且能上网。
sudo apt install openssh-server
ssh manager@192.168.56.101
下载安装OpenSSH for Windows,可以通过Windows使用ssh命令。
ifconfig
(linux中查看)或者 ipconfig
(Windows中查看)参考PredictableNetworkInterfaceNames
一言以蔽之,就是eth0,eth1规则升级为带有可预见拓扑关系的eth0s3,eth0s8等等,可以通过 ls /sys/class/net
查看
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有