Networking with virtual machines is often difficult to adjust. The most simple and most common settings is to enable the "bridged" mode which allows the virtual machine to obtain a dedicated IP on your network (if this network has DHCP enabled).
Several problems occur when you are in that mode :
When you install virtual box (it is probably the same for vmware workstation), virtual box creates a virtual network interface to communicate privately between your host and your guest. It is seen on windows as a real network interface:
It is possible then to declare the host-only adapter to be the network provider for the Virtual Machine in the network settings. The problem is then to declare a static IP in order to have a stable configuration.
To fix an IP address on the virtual machine, one have to modify the
/etc/sysconfig/network-scripts/ifcfg-enp0s3 (on CentOS) file with the following properties
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none 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=enp0s3 UUID=48e40e15-c66e-45b5-8e94-c092134b0d8f DEVICE=enp0s3 ONBOOT=yes IPADDR=192.168.137.10 PREFIX=24 GATEWAY=192.168.137.1 DNS1=22.214.171.124
Notice the IPADDR value : this is the new fixed IP, prefix and gateway can be determined from the characteristics of the virtual host adapter.
Then you can ping this new IP Address from your host to check connectivity.
One issue is that private network has no way to access the Internet. If you want to restore this access, you will have to share one Internet enabled connection with that host-only network. This can be done in the properties of the adapter settings that is connected to the external network : Right click on this adpater > Sharing > Set the connection name of yout host-only network.
If you try to reach an external IP (126.96.36.199 for instance), from your guest, you should be able to see some replies
What can be difficult is to work with several virtual machines having different IP addresses, and it can be difficult to remember what IP is associated to what virtual machine.
To solve that, there's a small trick that consist in forcing a DNS name in
# localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 192.168.137.10 myserver
you can then access to whatever is related to that machine with the name "myserver". It could be even more interresting, if this VM is to become a real server, to associate the final DNS name so that you will loose no configuration data.