-
Check whether the network connection set by the virtual machine is in NAT mode
-
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
your own gateway. Configure it in the server below. -
Enter the server's
/etc/sysconfig/network-scripts/
edit andifcfg-ens33
the original state is
modified to
where itBOOTPROTO
is static,GATEWAY
which is the gateway IP above,IPADDR
and 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
- Go back to the virtual network editor, remove this network, and add a new network that is the same as before.
Change the subnet IP to the original network IP,
click NAT settings, and set the subnet IP back to the original IP, consistent with the GATEWAY on the server.
- After the operation is completed, click Apply, then maintain the settings of this virtual machine and select the network you just added.
- Return to the virtual machine, use
ip addr
to view the IP address of the machine, and useservice network restart
to restart the network service to make the changes just made take effect.
7. Return to the physical host and cmd
try to ping the virtual machine network just now.
8. At this point, there will be no problem if you use SSH to connect.