Okay, this is a common issue where you have a network connection, but higher-level network services aren't working correctly. Let's go through the steps to diagnose and fix it, starting with the most likely culprits.
1. Basic Checks (Isolate the Problem)
- Reboot Everything: Turn off your laptop, your router, and your modem. Wait 30 seconds. Turn on the modem, wait for it to fully connect, turn on the router, wait for it to fully connect, then turn on your laptop.
- Try Another Device: Can another device (phone, another computer) access all websites on the same Wi-Fi network?
- If YES: The problem is likely specific to your Ubuntu laptop. Continue with the steps below.
- If NO: The problem is likely with your router, modem, or Internet Service Provider (ISP). Contact your ISP or troubleshoot your router.
- Try Another Network: If possible, connect your Ubuntu laptop to a different Wi-Fi network (e.g., a mobile hotspot, a friend's house). Does it work there?
- If YES: The problem is specific to your home network configuration or router settings related to your laptop.
- If NO: The problem is definitely with your Ubuntu laptop's configuration.
2. Check IP Address and Gateway
- Open a Terminal (Ctrl+Alt+T).
- Check your IP configuration:
ip addr show
Look for your wireless interface (often wlan0, wlpXsY, or similar). Does it have an IP address that looks reasonable for your network (e.g., 192.168.1.x, 10.0.0.x)? Or is it something strange like 169.254.x.x (which indicates a failure to get a proper IP from the router)?
- Check your routing table to find the default gateway:
ip route show
Look for the line starting with default via. The IP address after via is your gateway (router).
3. Test Basic Connectivity (Ping)
- Ping your gateway (replace
<gateway_ip> with the IP you found above):
ping <gateway_ip>
- If you get replies: Your laptop can communicate with the router. The issue is likely DNS or further upstream.
- If you get
Destination Host Unreachable or timeouts: Your laptop can't even talk to the router properly. Double-check your IP address (step 2). Maybe try removing and re-adding the Wi-Fi connection in Network Settings.
- Ping a reliable public IP address (like Google's DNS server):
ping 8.8.8.8
- If you get replies: Your laptop can reach the internet, but DNS resolution is likely the problem. Proceed to step 4.
- If you get timeouts (and pinging the gateway worked): The problem might be the router's connection to the internet, or a firewall setting on the router/laptop blocking traffic to external IPs.
- Ping a domain name:
ping google.com
- If this works, but pinging
8.8.8.8 didn't: Highly unlikely, but indicates a strange routing issue.
- If
ping 8.8.8.8 worked, but this fails: This strongly confirms a DNS issue. Proceed to step 4.
4. Troubleshoot DNS
DNS (Domain Name System) is what translates website names (like google.com) into IP addresses (like 172.217.160.142). If your DNS isn't working, you can only reach sites by their IP address (which is very difficult).
- Check DNS Server Settings:
- Click the network icon in the top-right corner -> Wi-Fi Settings (or Wired Settings if applicable).
- Click the gear icon next to your connected Wi-Fi network name.
- Go to the
IPv4 tab.
- How is DNS set?
- Automatic (DHCP): This usually relies on the DNS servers provided by your router. If the router is giving bad DNS info, this won't work.
- Automatic (DHCP) addresses only: This means it's not using the router's DNS settings.
- Manual: You've entered specific DNS servers.
- Try Public DNS Servers: The easiest fix is often to switch to reliable public DNS servers.
- In the same network settings window (IPv4 tab):
- Change the DNS method from "Automatic" to "Manual".
- In the DNS servers field, enter reliable ones, separated by a comma:
8.8.8.8, 8.8.4.4 (Google)
- OR
1.1.1.1, 1.0.0.1 (Cloudflare)
- Click "Apply".
- Turn Wi-Fi off and on again, or disconnect/reconnect the network.
- Try visiting websites again.
- Check
systemd-resolved Status: Ubuntu 22.04 uses systemd-resolved for DNS.
resolvectl status
Look for the section related to your Wi-Fi interface (linkX). Check the DNS Servers: listed there. Are they valid IPs? If it's blank or shows incorrect ones, it supports the DNS theory.
5. Check NetworkManager
NetworkManager is the service that handles network connections.
- Restart NetworkManager:
sudo systemctl restart NetworkManager
Wait a few seconds and see if connectivity improves.
- Check NetworkManager status for errors:
sudo systemctl status NetworkManager
Look for any red error messages.
- Examine your specific connection settings (replace
"Your Wifi Name" with the actual SSID):
nmcli connection show "Your Wifi Name"
Pay attention to lines related to ipv4.dns and ipv4.dns-search.
6. Check Firewall
It's possible a local firewall is interfering.
- Check UFW status (Uncomplicated Firewall):
sudo ufw status
- If it's
Status: active, try temporarily disabling it to see if that helps:
sudo ufw disable
- Test connectivity. If it works now, you need to configure
ufw correctly to allow necessary traffic. Re-enable it afterwards:
sudo ufw enable
7. Check for Proxies or VPNs
- Go back to your Wi-Fi connection settings (Network Settings -> Gear icon next to Wi-Fi). Check the
Proxy tab. Is anything configured there? If so, try setting it to "None" and test again.
- Are you running any VPN software? If so, try disconnecting from the VPN.
8. Check Drivers
While less likely if you connect successfully, sometimes driver issues cause weird problems.
Summary of Likely Fix:
The most common cause for "connected but cannot access sites" is DNS. Try setting your DNS servers manually to 8.8.8.8, 8.8.4.4 or 1.1.1.1, 1.0.0.1 in the network connection settings first.
If none of these steps work, please provide the output of the following commands from your terminal:
ip addr show
ip route show
resolvectl status
ping 8.8.8.8 (show the full output)
ping google.com (show the full output)
sudo ufw status