← Back
🖥️ Ubuntu 22.04 / 24.04

Configure static IPv4 on VMware Ubuntu VMs using Netplan. Uses modern routes: syntax and prevents cloud-init from reverting your config.

⚠️
SSH Safety: Applying Netplan can reset networking and disconnect your session. Use sudo netplan try so it auto-rolls back if something goes wrong.
0

Confirm Interface Name

Make sure your NIC is ens33 (VMware default).

bash
ip a
1

Disable cloud-init Networking

Stop cloud-init from overwriting your static IP on reboot.

bash
sudo mkdir -p /etc/cloud/cloud.cfg.d
sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Paste this content
network: {config: disabled}
2

Backup Existing Configs

Move auto-generated netplan configs created by cloud-init.

bash
sudo mkdir -p /root/netplan-backup
sudo mv /etc/netplan/50-cloud-init.yaml* /root/netplan-backup/ 2>/dev/null || true
3

Create Static Netplan File

Create one authoritative config file for VMware.

bash
sudo nano /etc/netplan/99-netcfg-vmware.yaml
3+

Netplan YAML Template

Change ens33, IP, gateway, and DNS as needed. Use 2-space indentation (no tabs).

99-netcfg-vmware.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:
      dhcp4: no
      addresses:
        - 10.10.1.70/24
      routes:
        - to: default
          via: 10.10.1.1
      nameservers:
        addresses:
          - 10.10.1.2
          - 10.10.1.3
💡
Tip: If VMware gives you a different interface (e.g., ens160), update the YAML key to match ip a output.
4

Validate the Config

No output is good; errors usually mean YAML indentation issues.

bash
sudo netplan generate
5

Apply Safely (SSH-safe)

Press ENTER when prompted to accept changes.

bash
sudo netplan try
sudo netplan apply
6

Verify Configuration

Confirm your IP, routes, and DNS are working.

bash
ip a
ip route
resolvectl status
ping -c 3 10.10.1.1
ping -c 3 google.com
7

Optional: Lock-down File

Prevents accidental edits to the netplan file.

bash
sudo chmod 600 /etc/netplan/99-netcfg-vmware.yaml
🔧

Troubleshooting Commands

bash
netplan get
networkctl status ens33
journalctl -u systemd-networkd -n 50 --no-pager
journalctl -u systemd-resolved -n 50 --no-pager