SSH connection to vmware virtual machine centos

  1. Check whether the network connection set by the virtual machine is in NAT mode
    Insert image description here

  2. Click "Edit" -> "Virtual Network Editor" in the upper left corner. View the IP address in the virtual network editor
    . After clicking on NAT mode, click "NAT Settings. Remember
    Insert image description here
    Insert image description here
    your own gateway. Configure it in the server below.

  3. Enter the server's /etc/sysconfig/network-scripts/edit and ifcfg-ens33
    Insert image description here
    the original state is
    Insert image description here
    modified to
    Insert image description here
    where it BOOTPROTOis static, GATEWAYwhich is the gateway IP above, IPADDRand which is the virtual machine network IP you want. Note that it must be in the same network segment, that is, only the last IP can be modified, refer to the following

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=89db0cec-c99a-4654-997c-c1a631095376
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.172.103
NTMASK=255.255.255.0
GATEWAY=192.168.172.2
DNS1=8.8.8.8
  1. Go back to the virtual network editor, remove this network, and add a new network that is the same as before.
    Insert image description here
    Change the subnet IP to the original network IP,
    Insert image description here
    click NAT settings, and set the subnet IP back to the original IP, consistent with the GATEWAY on the server.
    Insert image description here
  2. After the operation is completed, click Apply, then maintain the settings of this virtual machine and select the network you just added.
    Insert image description here
  3. Return to the virtual machine, use ip addrto view the IP address of the machine, and use service network restartto restart the network service to make the changes just made take effect.

Insert image description here
7. Return to the physical host and cmdtry to ping the virtual machine network just now.

Insert image description here
8. At this point, there will be no problem if you use SSH to connect.

Guess you like

Origin blog.csdn.net/weixin_45495923/article/details/131510328