Complete troubleshooting guide — from a broken VM with no network to a working Codex CLI install.
- Host OS: Windows 11
- Hypervisor: VMware Workstation Pro
- Guest OS: Ubuntu 22.04 LTS (Jammy)
- Network Mode: NAT
The VM's network adapter was disconnected. All commands run in PowerShell as Administrator.
Get-Service | Where-Object {$_.DisplayName -like "*VMware*"} | Select-Object DisplayName, Status, StartTypeEnsure these are Running:
- VMware Authorization Service
- VMware DHCP Service
- VMware NAT Service
- VMware USB Arbitration Service
Stop-Service "VMware NAT Service" -Force
Stop-Service "VMware DHCP Service" -Force
Start-Service "VMware DHCP Service"
Start-Service "VMware NAT Service"Get-NetAdapter | Where-Object {$_.InterfaceDescription -like "*VMware*"} | Select-Object Name, StatusBoth VMnet1 and VMnet8 should show Up. If not, re-enable:
Get-NetAdapter | Where-Object {$_.InterfaceDescription -like "*VMware*"} | Enable-NetAdapter -Confirm:$falseStart-Process "C:\Program Files (x86)\VMware\VMware Workstation\vmnetcfg.exe" -Verb RunAsInside the editor: Change Settings → Restore Defaults → OK
ip link showInterface will be something like ens33 (not ens160 as expected).
sudo ip link set ens33 up && sudo dhclient ens33The file was made immutable earlier. Unlock and rewrite it:
sudo chattr -i /etc/resolv.conf
printf "nameserver 8.8.8.8\nnameserver 8.8.4.4\n" | sudo tee /etc/resolv.confecho "127.0.1.1 MyPC" | sudo tee -a /etc/hostssudo tee /etc/systemd/resolved.conf > /dev/null <<EOF
[Resolve]
DNS=8.8.8.8 8.8.4.4
FallbackDNS=1.1.1.1
EOF
sudo systemctl restart systemd-resolvedprintf "network:\n version: 2\n ethernets:\n ens33:\n dhcp4: true\n" | sudo tee /etc/netplan/99-ens33.yaml
sudo netplan applyping -c 3 google.comsudo apt update && sudo apt install curl -ycurl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install nodejs -ynode --version # v22.x.x
npm --version # 10.x.xmkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrcnpm install -g @openai/codexcodex --versionexport OPENAI_API_KEY=your-api-key-here
codexTo make the API key permanent:
echo 'export OPENAI_API_KEY=your-api-key-here' >> ~/.bashrc
source ~/.bashrc| Problem | Root Cause | Fix |
|---|---|---|
| No internet in VM | VMware network adapter was disconnected | Enabled in VMware Settings + restored VMnet defaults |
ens160 not found |
Interface renamed to ens33 after VMware reset |
Used ip link show to find correct name |
| DNS failure | systemd-resolved not configured with upstream DNS |
Wrote Google DNS to /etc/resolv.conf + resolved.conf |
resolv.conf kept reverting |
File locked with chattr +i |
Unlocked with chattr -i |
sudo hostname warning |
MyPC not in /etc/hosts |
Added 127.0.1.1 MyPC to /etc/hosts |
| npm EACCES error | Global npm dir owned by root | Redirected global prefix to ~/.npm-global |
Tested on Ubuntu 22.04 LTS (Jammy) in VMware Workstation Pro on Windows 11, April 2026.