Hetzner服务器Netplan配置执行netplan apply后断连的诊断方法咨询
Hey there, let's walk through how to diagnose the connection loss you're seeing after running netplan apply on your Hetzner server. First, let's recap the config you shared (I've fixed the indentation to match YAML's strict requirements, since indentation breaks things easily here):
network: version: 2 renderer: networkd ethernets: eno1: dhcp4: no bridges: br0: interfaces: [eno1] addresses: - IP/32 routes: - on-link: true to: 0.0.0.0/0 via: Gateway nameservers: addresses: - 1.1.1.1 - 1.0.0.1
Now let's go through the key diagnostic steps:
First, validate your Netplan config syntax
YAML is super picky about indentation and formatting, so runsudo netplan generateto check for errors. This command parses your config and spits out issues like missing indentation, typos in field names, or invalid values before you apply it—catching these early saves you from unexpected disconnections.Check if your physical NIC needs promiscuous mode
Hetzner's network environment requires the physical ethernet port (eno1 in your case) to have promiscuous mode enabled for bridging to work properly. Add this line to your eno1 config:ethernets: eno1: dhcp4: no promiscuous: trueWithout this, the bridge might not forward traffic correctly, leading to lost connectivity.
Verify your IP and gateway settings
Double-check that theIP/32set for br0 is your server's actual main IP from Hetzner, and that theGatewayis the correct one listed in your Hetzner Robot dashboard (usually the first IP in your subnet). For /32 addresses, theon-link: trueflag in your routes is correct, but a wrong gateway will block all internet access.Inspect system logs for networkd errors
If you can access the server via Hetzner's KVM console or Rescue System, runjournalctl -u systemd-networkdto see detailed logs from the networkd renderer. Look for lines like "failed to bring up br0" or "eno1 cannot be added to bridge"—these point directly to what's failing.Temporarily restore connectivity to debug
If you're stuck disconnected, manually bring back the eno1 interface to regain access:- Bring down the bridge:
sudo ip link set br0 down - Bring up eno1:
sudo ip link set eno1 up - Assign your IP manually:
sudo ip addr add IP/24 dev eno1 - Set the default route:
sudo ip route add default via Gateway dev eno1
This lets you reconnect remotely so you can tweak the Netplan config safely.
- Bring down the bridge:
Test bridge connectivity locally first
Once you apply the config (and can access via KVM), run these commands to check the network state:ip addrto confirm br0 has the correct IP and eno1 is part of the bridgeip routeto verify the default route points to your gateway via br0ping Gatewayto check if you can reach the gateway directlyping 1.1.1.1to test DNS and internet connectivity
备注:内容来源于stack exchange,提问作者Mads Iversen

