VMware Ubuntu Static IP (Netplan) — 22.04 / 24.04

static IPv4 on VMware Ubuntu VMs using Netplan. Uses modern routes: syntax (no deprecated gateway4) and prevents cloud-init from reverting your config.

Target NIC: ens33 (change if needed)
SSH safety: applying Netplan can reset networking and disconnect your session. Use sudo netplan try so it auto-rolls back if something goes wrong.

Step 0 — Confirm interface name

Make sure your NIC is really ens33 (VMware often uses this).

ip a

Step 1 — Disable cloud-init networking

This stops cloud-init from overwriting your static IP on reboot.

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

Step 2 — Move auto-generated netplan configs

Back up anything created by cloud-init (commonly 50-cloud-init.yaml).

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

Step 3 — Create your static netplan file

Create one authoritative config file for VMware.

sudo nano /etc/netplan/99-netcfg-vmware.yaml

Step 3 (continued) — Paste this template (edit values only)

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

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 or ens34), update the YAML key under ethernets: to match ip a.

Step 4 — Validate the config

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

sudo netplan generate

Step 5 — Apply safely (SSH-safe)

Accept changes by pressing ENTER when prompted.

sudo netplan try
sudo netplan apply

Step 6 — Verify

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

Step 7 — Optional lock-down

Prevents accidental edits to the netplan file.

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

Troubleshooting commands

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