无法在主机上ping来宾IP 10.0.2.15

我是ubuntu的初学者,已经在台式计算机上安装了ubuntu 16.04,然后按照以下步骤安装了Vagrant

sudo apt-get install virtualbox
sudo apt-get install vagrant
vagrant box add ubuntu/xenial64
vagrant init ubuntu/xenial64
vagrant up
vagrant ssh

我可以访问它:

vagrant@ubuntu-xenial:~$ ifconfig

enp0s3    Link encap:Ethernet  HWaddr 02:ba:5f:3b:91:b0

           inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
           inet6 addr: fe80::ba:5fff:fe3b:91b0/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:282 errors:0 dropped:0 overruns:0 frame:0
           TX packets:201 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000 
           RX bytes:31982 (31.9 KB)  TX bytes:30222 (30.2 KB)

 lo        Link encap:Local Loopback  

           inet addr:127.0.0.1  Mask:255.0.0.0
           inet6 addr: ::1/128 Scope:Host
           UP LOOPBACK RUNNING  MTU:65536  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

所以我试图将主机ping到10.0.2.15,但是...

admin@admin-desktop:~$ ping 10.0.2.15

PING 10.0.2.15 (10.0.2.15) 56(84) bytes of data.

什么都没发生。

访客的IP路由输出

 vagrant@ubuntu-xenial:~$ ip route
 default via 10.0.2.2 dev enp0s3 
 10.0.2.0/24 dev enp0s3  proto kernel  scope link  src 10.0.2.15 

主机上的IP路由输出

 admin@admin-desktop:~$ ip route
 default via 172.16.20.1 dev enp3s0  proto static  metric 100 
 169.254.0.0/16 dev enp3s0  scope link  metric 1000 
 172.16.20.0/24 dev enp3s0  proto kernel  scope link  src 172.16.20.187  metric 100 

我尝试将NAT设置为Bridge适配器显示以下错误

admin@admin-desktop:~$ vagrant reload
==> default: Attempting graceful shutdown of VM...
default: Guest communication could not be established! This is usually because
default: SSH is not running,the authentication information was changed,default: or some other networking issue. Vagrant will force halt,if
default: capable.
==> default: Forcing shutdown of VM...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: A newer version of the box 'ubuntu/xenial64' is available! You currently
==> default: have version '20191108.0.0'. The latest is version '20191113.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
There was an error while executing `VBoxManage`,a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm","49520cee-d0ee-43e3-869c-4f78e1fb9dfd","--natpf1","ssh,tcp,127.0.0.1,2222,22"]

Stderr: VBoxManage: error: A NAT rule of this name already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057),component NATEngineWrap,interface INATEngine,callee nsISupports
VBoxManage: error: Context: "AddRedirect(Bstr(strName).raw(),proto,Bstr(strHostIp).raw(),RTStrToUInt16(strHostPort),Bstr(strGuestIp).raw(),RTStrToUInt16(strGuestPort))" at line 1838 of file VBoxManageModifyVM.cpp
enter code here
nimadedajibamaochuiz 回答:无法在主机上ping来宾IP 10.0.2.15

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3111153.html

大家都在问