Skip to Content

Quick Diagnosis

# Check network interface status ip link show # Check IP addresses ip addr show # Test network connectivity ping -c 4 8.8.8.8 # Test DNS resolution ping -c 4 www.google.com # Check NetworkManager status nmcli general status

Wired Network

Network card not recognized

# Check Ethernet devices lspci | grep -i ethernet ip link show | grep -E "^[0-9]" # If the network card is not shown, check the driver sudo dmesg | grep -i eth sudo dmesg | grep -i r8169 # Common Realtek driver

No IP address obtained

# Have NetworkManager re-request an address (dhclient is no longer shipped) sudo nmcli device reapply enp0s3 # On systemd-networkd systems use instead: sudo networkctl renew enp0s3 # Or reconnect the interface sudo nmcli device connect enp0s3 # Manually configure a static IP sudo nmcli con mod "Wired connection 1" \ ipv4.addresses 192.168.1.100/24 \ ipv4.gateway 192.168.1.1 \ ipv4.dns "8.8.8.8,1.1.1.1" \ ipv4.method manual sudo nmcli con up "Wired connection 1"

Wireless Network

Wi-Fi adapter not detected

# Check wireless devices (iwconfig is deprecated; use iw) iw dev nmcli device wifi list # Check if disabled by RF switch rfkill list all sudo rfkill unblock wifi

Cannot connect to Wi-Fi

# Scan for available networks nmcli device wifi rescan nmcli device wifi list # Connect to Wi-Fi nmcli device wifi connect "SSID_NAME" password "PASSWORD" # View saved connections nmcli connection show # Delete a problematic connection and re-add nmcli connection delete "CONNECTION_NAME"

Frequent disconnections

# Check if power management turned off Wi-Fi iw dev wlan0 get power_save # Disable Wi-Fi power management sudo iw dev wlan0 set power_save off # Make it permanent echo 'options iwlwifi power_save=0' | sudo tee /etc/modprobe.d/iwlwifi-powersave.conf

DNS Issues

Symptom: IPs work, names do not

# 1. Does the IP layer work at all (bypasses DNS entirely)? ping -c 2 223.5.5.5 # 2. Does name resolution fail? getent hosts archive.ubuntu.com

If step 1 succeeds and step 2 hangs or reports that the name cannot be resolved, the problem is DNS, not the link. This is easy to misread as “no internet”, and the apt errors it produces look like the repository is unreachable.

Three commands to locate it

# 1. Which DNS server is this machine using? resolvectl status # 2. Ask that server directly (use the address from step 1) dig +short @223.5.5.5 archive.ubuntu.com # 3. Compare against a public resolver dig +short @119.29.29.29 archive.ubuntu.com

dig comes from the dnsutils package (sudo apt install dnsutils); getent hosts <name> goes through the system resolver if you prefer not to install anything.

The three outcomes map to three causes:

What you seeCauseFix
The configured server does not answer (step 2 empty or timing out) while a public one worksDHCP handed out an unusable DNS, usually because the router’s own forwarder diedChange DNS, next section
Neither answersOutbound blocked, or the upstream is downSee Firewall Issues and verify the gateway is reachable
Both answer but resolution still failsLocal cache or proxy settingssudo resolvectl flush-caches and retry

Changing DNS: temporary and permanent

Temporary (gone after reboot, the usual first aid):

# Replace ens18 with your interface name; `ip -brief addr` shows it sudo resolvectl dns ens18 223.5.5.5 sudo resolvectl flush-caches

For a permanent change, first find out what manages the interface:

nmcli -t -f NAME,DEVICE con show --active

NetworkManager (the desktop default):

sudo nmcli con mod "netplan-ens18" ipv4.dns "223.5.5.5 119.29.29.29" sudo nmcli con mod "netplan-ens18" ipv4.ignore-auto-dns yes sudo nmcli con up "netplan-ens18"

The connection name must match the output above. A wrong name fails with “unknown connection”, which is easy to miss and leaves everything unchanged.

netplan (edits the config file, survives reboots, recommended):

sudo nano /etc/netplan/00-installer-config.yaml
network: ethernets: ens18: dhcp4: true dhcp4-overrides: use-dns: false # key: stop accepting DNS from DHCP nameservers: addresses: [223.5.5.5, 119.29.29.29] version: 2

Then apply:

sudo netplan apply

use-dns: false is the important part. Without it the broken address from DHCP is merged back in, and resolvectl status shows your server and the bad one side by side.

The host resolves, the virtual machine does not

When the host — or any other machine on the LAN — resolves fine and only one VM fails, the router is usually advertising itself as DNS while its forwarder is dead.

Confirm it:

# Run this on both the VM and the host, with your gateway address dig +short @192.168.1.1 archive.ubuntu.com

No answer on either machine means the gateway’s forwarding is broken. Three ways out:

  1. Fix the router’s DHCP/WAN DNS settings (recommended — repairs every device at once)
  2. Run a resolver on the LAN (for example dnsmasq on an always-on host) and point the VMs at it
  3. Change only this VM’s netplan to a public resolver (most local, but you repeat it per machine)
ProviderPrimarySecondary
Alibaba Cloud223.5.5.5223.6.6.6
Tencent DNSPod119.29.29.29—
114 DNS114.114.114.114114.114.115.115
Google8.8.8.88.8.4.4

Firewall Issues

# Check UFW status sudo ufw status verbose # Temporarily disable firewall for testing sudo ufw disable # Allow specific ports sudo ufw allow 80/tcp sudo ufw allow 443/tcp

Proxy Settings

System Proxy

# Set environment variables export http_proxy="http://127.0.0.1:7890" export https_proxy="http://127.0.0.1:7890" export no_proxy="localhost,127.0.0.1" # Write to ~/.bashrc for permanence

APT Proxy

sudo nano /etc/apt/apt.conf.d/proxy.conf
Acquire::http::Proxy "http://127.0.0.1:7890"; Acquire::https::Proxy "http://127.0.0.1:7890";

Reset Network Configuration

# Restart NetworkManager sudo systemctl restart NetworkManager # Completely reset network configuration sudo rm /etc/NetworkManager/system-connections/* sudo systemctl restart NetworkManager
Last updated on