To resolve static IP assignment issues for Kali and Ubuntu VMs in VMware Workstation Pro, you must ensure the virtual network adapter is correctly configured to use NAT or Host-Only mode rather than Bridged. This prevents IP conflicts with your physical router and allows manual configuration within the guest OS without losing connectivity.
Understanding the Network Adapter Configuration
The root cause of most static IP failures in VMware involves a mismatch between the host’s virtual network settings and the guest operating system’s expectations. By default, new virtual machines often receive an IP address via DHCP from VMware’s internal server. When you attempt to switch to a static IP, the connection drops if the underlying virtual network (such as vmnet8) is not properly mapped to your host machine’s physical interface.
VMware Workstation uses several virtual networks. The most common are:
- vmnet0 (Bridged): Connects the VM directly to the host’s physical network. If your physical router assigns IPs dynamically, setting a static IP in the VM can conflict with the router’s DHCP pool or fail if the VM cannot reach the gateway.
- vmnet1 (Host-Only): Creates an isolated network between the host and VMs. No external internet access is provided by default unless NAT is enabled.
- vmnet8 (NAT): Allows VMs to access the internet through the host’s IP while keeping them isolated from the local LAN. This is the recommended mode for development environments like Kali Linux.
For two VMs running Kali and Ubuntu, using vmnet8 ensures they share the host’s internet connection but have their own private subnet. This isolation makes assigning static IPs safe because they will not interfere with other devices on your physical network.
Configuring VMware Virtual Network Editor
Before configuring the guest OS, you must verify that VMware’s virtual network infrastructure is set up correctly. Open VMware Workstation Pro and navigate to
Edit >
Virtual Network Editor. You may need administrator privileges to make changes.
Select
vmnet8 (NAT) from the list. Ensure that the checkbox
Use local DHCP service to distribute IP addresses to VMs is unchecked if you plan to assign static IPs manually. If this box is checked, VMware’s internal DHCP server might override your manual settings or cause conflicts during boot. Note the Subnet IP and Subnet Mask displayed here; these define the range for your virtual network. For example, it might be 192.168.137.0/24.
If you are experiencing connectivity issues similar to those described in
WSL and VM: Unable to Connect WSL2 Ubuntu to VMware VM, verifying the NAT settings is a critical first step. Incorrect NAT configurations can prevent any traffic from leaving the virtual environment, making static IP assignment irrelevant because there is no route to begin with.
Setting Static IPs in Kali Linux
Modern versions of Kali Linux use Netplan for network configuration. To assign a static IP, you must edit the YAML configuration file located in
/etc/netplan/. Identify the configuration file, which usually has a name like
50-cloud-init.yaml or
01-netcfg.yaml.
Open the terminal and use a text editor such as
nano or
vim to modify the file. You need to specify the network interface, typically
ens33 or
eth0, depending on your VMware version. The configuration should look something like this:
network:
version: 2
ethernets:
ens33:
dhcp4: no
addresses:
- 192.168.137.10/24
routes:
- to: default
via: 192.168.137.2
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
In this example:
- addresses: Set to a static IP within the vmnet8 subnet (e.g., .10).
- routes via: Points to the VMware NAT gateway, which is usually the second IP in the subnet (e.g., .2).
- nameservers: Specifies DNS servers. Google’s public DNS (8.8.8.8) is reliable for testing.
After saving the file, apply the changes by running
sudo netplan apply. If the command fails, check the syntax carefully, as YAML is sensitive to indentation errors. Verify connectivity by pinging the gateway (
ping 192.168.137.2) and an external site (
ping 8.8.8.8).
Configuring Static IPs in Ubuntu
Ubuntu Server and Desktop versions also utilize Netplan in recent releases. The process is nearly identical to Kali Linux. Locate the configuration file in
/etc/netplan/. If you installed Ubuntu recently, it might have generated a cloud-init configuration that overrides manual edits. In such cases, you may need to disable cloud-init networking or edit the correct Netplan file that controls the primary interface.
Ensure that the
dhcp4 parameter is set to
false. Define the static IP, gateway, and DNS servers just as you did for Kali. It is crucial that both VMs use different static IPs within the same subnet to avoid ARP conflicts. For instance, if Kali is 192.168.137.10, set Ubuntu to 192.168.137.11.
Once configured, run
sudo netplan apply. If you encounter issues where the VM loses connectivity after applying the config, revert to DHCP temporarily to confirm that the network adapter itself is functioning. Sometimes, simply restarting the network manager service (
sudo systemctl restart systemd-networkd) can resolve transient binding issues.
Verifying Connectivity and Troubleshooting
After setting static IPs for both VMs, test the communication path. From the host machine, you should be able to ping both VMs. From each VM, you should be able to ping the other VM, the gateway, and external websites.
If you cannot ping the gateway, check the VMware Virtual Network Editor again to ensure the NAT gateway IP matches the one specified in your Netplan configuration. A common mistake is assuming the gateway is always .1; in VMware’s default NAT setup, it is often .2.
If you face difficulties copying files between the host and VMs, refer to
Error Copying Virtual Machine File for solutions related to file transfer mechanisms, which can sometimes be confused with network configuration problems. Additionally, ensure that firewalls within Kali and Ubuntu are not blocking ICMP (ping) requests. You can temporarily disable the firewall with
sudo ufw disable for testing purposes.
Frequently Asked Questions
Why does my VM lose internet access after setting a static IP?
This usually happens because the gateway or DNS settings in the guest OS do not match the VMware NAT configuration. Verify that the "via" IP in your Netplan file corresponds to the NAT Gateway IP shown in VMware’s Virtual Network Editor.
Can I use Bridged mode instead of NAT for static IPs?
Yes, but it is riskier. In Bridged mode, your VM appears as a distinct device on your physical LAN. If you set a static IP that conflicts with another device or the router’s DHCP range, you will lose connectivity. NAT isolates the VM, making static assignment safer.
How do I find the correct network interface name in Kali?
Run the command
ip link show in the terminal. Look for an interface that is not
lo (loopback). Common names include
ens33,
eth0, or
enp0s3. Use this exact name in your Netplan configuration.
What if Netplan apply fails with a syntax error?
Netplan uses YAML, which is strict about indentation. Ensure you are using spaces, not tabs, and that the hierarchy is correct. Run
netplan generate to debug the configuration before applying it, as this command often provides more detailed error messages.
Do I need to configure the host firewall for VM-to-VM communication?
Generally, no. Since both VMs are on the same virtual network (vmnet8), they communicate directly through the virtual switch. However, ensure that the internal firewalls within Kali and Ubuntu allow traffic on the required ports, especially if you are running services like SSH or web servers.