• 虚拟机利用Host-only实现在不插网线的情况下,虚拟机与主机实现双向通信,实现ssh连接以及samba服务实现共享


    • 为了不影响其他的虚拟网卡,我们在VMware下在添加一块虚拟网卡:

    image

    image

    然后点击Next,选择连接方式:

    image

    点击Finish即可。

    重新启动虚拟机,如果这是你手动添加的第一块虚拟网卡,那么应该是eth1。

    • 配置eth1的ip信息

    image

    可以看到,VMnet1的type就是Host-only,我们看一下他的DHCP setting信息:

    image

    根据上面的信息,可以将eth1设置为跟VMnet1处于同一个网段,并将设置信息填写在 /etc/network/interfaces中,比如像如下信息:

    # This file describes the network interfaces available on your system                                                                   
    # and how to activate them. For more information, see interfaces(5).
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto eth0
    iface eth0 inet static
    address 192.168.8.129
    netmask 255.255.255.0
    network 192.168.8.0
    broadcast 192.168.8.255
    gateway 192.168.8.1
    
    auto eth0:1
    iface eth0:1 inet static
    address 192.168.253.129
    netmask 255.255.255.0
    
    auto eth1
    iface eth1 inet static
    address 192.168.229.129
    netmask 255.255.255.0

    这里只需要看eth1的配置即可,不用看其他的。

    然后重新启动网络服务   sudo /etc/init.d/networking restart

    image

    • 测试(为了准确点,拔掉网线)

    在宿主机下面ping虚拟机   

    image

    在虚拟机下面ping宿主机:

    image

    或者虚拟机可以ping一下宿主机的其他ip,比如我的宿主机上网的ip是192.168.8.129

    image

    • 用samba服务实现共享(samba的配置过程这里不介绍),同样为了准确一些,还是拔掉网线。

    image

    image

    点击完成即可。这样就可以在我的电脑下面出现一个映射出来的网络驱动器。

    • SSH连接,同样为了准确一些,还是拔掉网线。这里使用secureCRT作为客户端

    image

    image 

     

    进行连接测试:

    image

     

    image

     

    image

     

    连接成功。

  • 相关阅读:
    mvc的cshtml Request取不到值
    entityframework导航属性筛选
    关于引用类型一个有意思的测试
    如何去除decimal后面的零?
    webapi调用post时自动匹配参数
    entityframework删除时提示“DELETE 语句与 REFERENCE 约束”的解决方法。
    FormsAuthenticationTicket学习笔记
    mvc部署
    redis 订阅发布 事务 WATCH 乐观锁
    idea==>gitee
  • 原文地址:https://www.cnblogs.com/pengdonglin137/p/3323663.html
Copyright © 2020-2023  润新知