Virtualbox 流浪汉:一种更好的生活方式;重置";我的客人流浪汉vm';s网络?
我对流浪汉还比较陌生,但到目前为止我确实喜欢它 我经常面临的一个小问题是,当我的主机的网络暂时关闭时,它会影响我与我的流浪客vm的连接 当我的主机的网络再次恢复时,我必须在我的主机上运行Virtualbox 流浪汉:一种更好的生活方式;重置";我的客人流浪汉vm';s网络?,virtualbox,vagrant,Virtualbox,Vagrant,我对流浪汉还比较陌生,但到目前为止我确实喜欢它 我经常面临的一个小问题是,当我的主机的网络暂时关闭时,它会影响我与我的流浪客vm的连接 当我的主机的网络再次恢复时,我必须在我的主机上运行vagrant halt,然后运行vagrant up,以便“重置”我的来宾vagrant vm的网络,以便它可以再次连接到internet 是否有一种更“优雅”的方法通过主机的网络获取虚拟机的internet连接,以检测internet网络连接是否已备份?是的,最简单的解决方案是重新启动虚拟机内部的网络子系统。
vagrant halt
,然后运行vagrant up
,以便“重置”我的来宾vagrant vm的网络,以便它可以再次连接到internet
是否有一种更“优雅”的方法通过主机的网络获取虚拟机的internet连接,以检测internet网络连接是否已备份?是的,最简单的解决方案是重新启动虚拟机内部的网络子系统。SSH连接不应该被中断。在Ubuntu上,执行以下操作:
sudo /etc/init.d/networking restart
以下是我所做的:
主机=虚拟机IP地址
私钥路径=私钥路径
ssh vagrant@$HOST-i$PRIVATE\u KEY\u PATH
登录到虚拟机
然后,
sudo/etc/init.d/networking restart
关于Mitchell的回答,对于我的Vagrant版本1.5.2,命令有点不同:
sudo/etc/init.d/network restart
而不是使用“网络”。我知道这没什么大不了的,但我只是想说出来
和流浪汉米切尔合作得很好 其他答案中所列命令的更新版本(2018年)*:
对于Ubuntu 16.04.*LTS(Xenial Xerus):
对于CentOS 7.5(network
vsnetworking
是一个非常不幸的区别,但我们做到了):
*在现代发行版中,答案中列出的脚本只是对
systemd
的systemctl
的包装,作为一个注释可能会更好。您可能使用的是CentOS/Red Hat/Fedora虚拟机,而不是Ubuntu/Debian虚拟机。对于我来说,使用Debian和config.VM.network:public\u network,bridge:'en0:Wi-Fi(机场)
在vagrant文件中
我需要做:sudo-ifdown-eth2和&sudo-ifup-eth2
sudo systemctl restart networking
# Check the status - there is no better way with systemd for now:
# https://github.com/systemd/systemd/issues/1287
sudo systemctl status networking
sudo systemctl restart network
# Check the status - there is no better way with systemd for now:
# https://github.com/systemd/systemd/issues/1287
sudo systemctl status network