English
macOS VMware Fusion Ubuntu Virtual Machine Static IP Configuration Pitfall Record

The Entire Troubleshooting Process for a "Mysterious" Network Problem Caused by an Incorrect Gateway Address
Background
Running an Ubuntu 22.04 virtual machine with VMware Fusion on macOS, after configuring a static IP the network is unreachable, but everything works fine in DHCP mode.
symptom
| phenomenon | Status |
|---|---|
ping 192.168.101.1(host bridge) | Through |
ping 8.8.8.8(Public IP) | Not through |
ping bing.com | Unreachable (DNS cannot resolve it either) |
| DHCP mode | Completely normal |
Misconfiguration
yaml
network:
version: 2
ethernets:
ens33:
dhcp4: false
addresses:
- 192.168.101.100/24
routes:
- to: default
via: 192.168.101.1 # Error! This is the host bridge, not the NAT gateway.
nameservers:
addresses:
- 223.5.5.5
- 114.114.114.114Troubleshooting process
1. Confirm that the IP has taken effect
bash
ip addr show ens33
# inet 192.168.101.100/24 ... Static IP is now active2. Test gateway connectivity
bash
ping 192.168.101.1
# 64 bytes from 192.168.101.1 ... The gateway can be pinged.3. Test external network connectivity
bash
ping 8.8.8.8
# 100% packet loss, external network unreachable4. Check the routing table
bash
ip route show | grep default
# default via 192.168.101.2 dev ens33 proto dhcp src 192.168.101.129 metric 100Key findings: The gateway obtained in DHCP mode is 192.168.101.2, rather than 192.168.101.1!
5. Check the host network interfaces
bash
ifconfig
# bridge102: inet 192.168.101.1 ← This is the host-side bridge interfaceRoot cause analysis
In a VMware Fusion NAT network, IP addresses are assigned as follows:
| IP address | Role | Description |
|---|---|---|
192.168.101.1 | Host bridge | The bridge102 interface on macOS, used for communication between the host and virtual machines. |
192.168.101.2 | NAT Gateway | The address that the VMware NAT service (vmnet-natd) listens on, responsible for forwarding traffic to the external network |
192.168.101.128/129 | Virtual machine IP | The address assigned to the virtual machine by DHCP |
Therefore:
192.168.101.1= Host bridge (virtual machine ↔ host machine)192.168.101.2NAT gateway (virtual machine ↔ external network)
Point the default route to 192.168.101.1, the packets stop once they reach the host bridge and cannot be forwarded to the external network.
Correct configuration
Step 1: First use DHCP to obtain the correct gateway address.
bash
sudo dhclient -v ens33
ip route show | grep default
# default via 192.168.101.2 dev ens33 ... ← Note down this gateway addressStep 2: Disable cloud-init (to prevent it from being overwritten after reboot)
bash
sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg <<EOF
network: {config: disabled}
EOFStep 3: Configure static IP
bash
sudo tee /etc/netplan/50-cloud-init.yaml <<'EOF'
network:
version: 2
ethernets:
ens33:
dhcp4: false
addresses:
- 192.168.101.100/24
routes:
- to: default
via: 192.168.101.2 # Key: Use the gateway obtained via DHCP.
nameservers:
addresses:
- 223.5.5.5
- 114.114.114.114
EOFStep 4: Apply configuration
bash
sudo netplan applyStep 5: Verification
bash
ping 8.8.8.8
ping bing.comPitfall Avoidance Guide
| pit | Correct approach |
|---|---|
Write the network card name.eth0 | Ubuntu 22.04 实际网卡名是 ens33 |
Gateway write 192.168.101.1 | Use first ip route show View the actual gateway obtained via DHCP |
Write gateway comments gateway4 | Ubuntu 22.04 is deprecated gateway4, must use routes |
| cloud-init is not disabled | The configuration will be overwritten on every restart; you need to add 99-disable-network-config.cfg |
Summary
Core lesson: When configuring a static IP,Don't make up the gateway address. The correct approach is:
Start in DHCP mode first.
Execute
ip route show | grep defaultGet the real gatewayConfigure a static IP using this gateway.
bash
# Golden Triple Combo
sudo dhclient -v ens33 # Get DHCP assignment
ip route show | grep default # View real gateway
# Configure a static IP using the discovered gateway.This document was recorded on 2026-08-20, macOS 13.3.1 + VMware Fusion 13.6.3 + Ubuntu 22.04