zoukankan      html  css  js  c++  java
  • 虚拟机利用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

     

    连接成功。

  • 相关阅读:
    docker-compose
    Cassandra
    npm常用命令
    k8s linux win10
    wsl2 docker 迁移
    docker http 代理
    mysql查看当前所有的数据库和索引大小
    mybatis 遍历list拼接 or查询
    es head crud
    nginx 代理转发mysql
  • 原文地址:https://www.cnblogs.com/pengdonglin137/p/3323663.html
Copyright © 2011-2022 走看看