Comprehensive Guide to Setting Up a VMware Virtual Machine with CentOS 7.8 and Network Configuration
This article provides a step‑by‑step tutorial on installing VMware Workstation, creating a CentOS 7.8 virtual machine, configuring bridge and NAT networking, adjusting network scripts, installing Java, deploying services, and troubleshooting firewall settings to enable a fully functional test environment.
1. Introduction
Developers often test projects locally and then deliver WAR packages to operations via Jenkins or similar tools. For small companies, purchasing a dedicated cloud server for testing is costly, so a local computer can be partitioned with virtualization software to create isolated environments and save resources.
The author uses the trial version of VMware to install a virtual machine, selects the CentOS 7.8 minimal ISO from the Alibaba Cloud mirror, and proceeds with a straightforward installation.
2. Installing the Image
Open VMware and click "Create a New Virtual Machine".
Choose the recommended configuration.
Select the downloaded CentOS 7.8 ISO ( CentOS-7-x86_64-Minimal-2003.iso ).
Proceed through the wizard until the VM is created and the OS installation completes.
3. Network Introduction
VMware offers two networking modes: bridge mode (recommended) and NAT mode.
3.1 Bridge Mode (Recommended)
In bridge mode the VM appears as a separate host on the same LAN, allowing it to communicate with all other hosts. Manual configuration of subnet mask, gateway, and DNS is required.
3.2 NAT Mode
In NAT mode the VM accesses the external network through the host's IP address, making the VM invisible to other machines on the LAN.
4. Environment Configuration
Since the goal is for all machines in the LAN to reach the VM, bridge mode is required.
Open the Virtual Network Editor and click "Edit".
Select VMnet0 , set it to Bridge mode , and choose the appropriate host network adapter (determine the correct adapter via Task Manager).
For the VM, edit the network script (CentOS 7: vi /etc/sysconfig/network-scripts/ifcfg-ens33 , CentOS 6: vi /etc/sysconfig/network-scripts/ifcfg-eth0 ).
Add the following lines (default is DHCP): ONBOOT=yes NETMASK=255.255.252.0 GATEWAY=197.168.24.1 DNS1=197.168.12.2
To use a static IP, modify BOOTPROTO to static and add: IPADDR=197.168.24.201 ONBOOT=yes NETMASK=255.255.252.0 GATEWAY=197.168.24.1 DNS1=197.168.12.2
Restart the network service: systemctl restart network
Verify connectivity with ping www.baidu.com and check the network interfaces using ip addr or ifconfig (install net-tools if necessary: yum install net-tools ).
5. Project Deployment
After network configuration, install services and deploy the project.
Install JDK: yum -y install java-1.8.0-openjdk
Verify installation with java -version .
Upload JAR/WAR files to the VM using WinSCP.
Remote‑login to the VM (e.g., with Xshell) and start the service: # Start a JAR service and log output nohup java -jar service.jar > service.log 2>&1 &
If the firewall blocks access, check its status and stop/disable it: # Check firewall status systemctl status firewalld.service # Stop firewall systemctl stop firewalld.service # Disable on boot systemctl disable firewalld.service
6. Summary
The author emphasizes that network configuration is the most error‑prone part; ensure you identify the correct host network adapter before setting bridge mode.
7. References
1. 秋夜雨巷 – VMware Virtual Machine Network Configuration
Full-Stack Internet Architecture
Introducing full-stack Internet architecture technologies centered on Java
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.