Configuring NAT Internet Access and Static IP for CentOS on VMware

When running CentOS 7 virtual machines on VMware, dynamically assigned IP addresses change frequently, disrupting consistent network access. Configuring a static IP maintains stable connectivity between the VM and local network, follow the steps below to complete setup:

  1. Launch VMware with system administrator privileges
  2. Open the Virtual Network Editor menu option
  3. Select the VMnet8 virtual network entry
  4. Restore VMnet8 to its default configuration
  5. Adjust VMnet8 parameters. You may customize the subnet IP and subnet mask, but default values work for most deployments
  6. Open the NAT configuration panel
  7. Save all changes to the virtual network settings
  8. Confirm your target CentOS virtual machine is configured to use NAT networking mode
  9. Power on the CentOS 7 virtual machine

Configure Static IP Address on CentOS 7

Use vi to edit your network interface configuration file, located at /etc/sysconfig/network-scripts/. The default filename is often ifcfg-ens33, but run the following command to confirm your actual interface name:

ls /etc/sysconfig/network-scripts

Make the following modifications to the configuration file:

  1. Update the BOOTPROTO parameter to enable static IP addressing:
BOOTPROTO=static # dhcp = dynamic address assignment, static = fixed static assignment
  1. Update the ONBOOT parameter to enable the network interface on system boot:
ONBOOT=yes # controls whether the interface is activated at system startup
  1. Add DNS server configuration:
DNS1=114.114.114.114 # Primary DNS server address
DNS2=192.168.226.2 # Secondary DNS server, typically set to match the gateway
  1. Add static IP, subnet mask, and default gateway configuration:
IPADDR=192.168.226.128 # Static IP address for your virtual machine
NETMASK=255.255.255.0 # Subnet mask for the private network
GATEWAY=192.168.226.2 # Default gateway matching VMnet8 NAT settings

Apply Network Changes

Restart the network service to apply your new configuration:

systemctl restart network

Verify Connectivity

Test internet connectivity by pinging a public domain to confirm the setup works.

Fix Common Connectivity Issue: Host Cannot Ping VM

If your CentOS VM can ping the host machine, but the host cannot ping the VM, adjust the host's VMnet8 adapter configuration:

The host accesses the VM through the VMware Network Adapter VMnet8 interface on the host. For connectivity to work, this interface must share the same subnet as the VM, with matching subnet mask and gateway.

For example, if your CentOS VM has the following network configuration:

IPADDR=192.168.226.128
NETMASK=255.255.255.0
GATEWAY=192.168.226.2

Set the host's VMware Network Adapter VMnet8 interface to an unused IP in the 192.168.226.x range, with matching subnet mask and gateway values.

Tags: Linux centos VMware NAT Networking Static IP Configuration

Posted on Fri, 03 Jul 2026 17:45:31 +0000 by BETA