Score:-2

Ubuntu 20 & 22 connect to local network but no internet

ag flag

I was having this issue with my install of 20.04 and in an attempt to fix it I upgraded to 22.04. Both systems exhibited the same behavior I'll detail here.

The machine is able to connect to my local network fine. I can access other devices within the network, including the router, with no problem. Likewise, I can access the machine from other machines in the network via ssh with no problem. When I try to connect to the internet via this machine, nothing works regardless of if I'm using a wired or wireless connection. Every other device on the network seems to have no problem reaching the internet.

To test the connection I've tried loading webpages and ping ing various nameservers (1.1.1.1 and 8.8.8.8), all with no success. I've also tried each combination of IPv4 and IPv6 enabled/disabled on both the wired and wireless connections, reset my router, just waiting indefinitely, and even used a version of Ubuntu running from a flash drive in "try ubuntu" mode. These last two strategies are the only ones that have shown any progress.

While using this last strategy (ubuntu from a USB device) everything worked perfectly fine. I could ssh to other devices on the network, access webpages, ping nameservers, etc. That makes me believe that the problem is with some configuration in my machine.

As for the waiting strategy, everything seems to fix itself temporarily every few minutes. As I was typing this out on another device, the machine in question suddenly loaded the webpage I had it pointed to, and then a few minutes later it seemed to lose the connection again.


For background, here are some relevant files and outputs:

/etc/netplan/01-netcfg.yaml (the only file in /etc/netplan/, and the file used last time I ran sudo netplan apply):

network:
  version: 2
  renderer: NetworkManager

/etc/NetworkManager/NetworkManager.conf:

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

/etc/resolv.conf (symlink to /run/systemd/resolve/stub-resolv.conf) minus the header comment:

nameserver 127.0.0.53
options edns0 trust-ad
search Home

/run/systemd/resolve/resolv.conf again minus the header comment:

nameserver 192.168.0.1
nameserver 205.171.3.65
nameserver 192.168.0.1
# Too many DNS servers configured, the following entries may be ignored.
nameserver 205.171.3.65
search Home

And the last one I can think of, /etc/NetworkManager/conf.d/10-globally-managed-devices.conf:

[keyfile]
unmanaged-devices=*,except:type:ethernet,except:type:wifi,except:type:wwan

Output of ip a:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp37s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 70:85:c2:a1:9e:2b brd ff:ff:ff:ff:ff:ff
3: wlp36s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 30:24:32:bd:75:0e brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.102/23 brd 192.168.1.255 scope global dynamic noprefixroute wlp36s0
       valid_lft 81712sec preferred_lft 81712sec

Output of nmcli c show (yes, the wifi name is :^) but that's never been a problem before):

NAME                UUID                                  TYPE      DEVICE
:^)                 a48206d0-c23c-4634-b867-d743cec84e67  wifi      wlp36s0
Wired connection 1  1ee423fe-8374-3689-b786-f46ea5ef193f  ethernet  enp37s0

If there are other files or command outputs that would help diagnose this I'm happy to post them, I just don't know what to check beyond these files. Alternatively, if there's some utility I could send over to the machine from another computer that could have a shot at fixing the configuration, I'd happily give that a shot.


EDIT:

Per @netbat, here are the outputs of ip route:

default via 192.168.0.1 dev enp37s0 proto dhcp metric 100
default via 192.168.0.1 dev enp37s0 proto dhcp src 192.168.0.61 metric 100
default via 192.168.0.1 dev wlp36s0 proto dhcp metric 600
169.254.0.0/16 dev wlp36s0 scope link metric 1000
192.168.0.0/23 dev enp37s0 proto kernel scope link src 192.168.0.61
192.168.0.0/23 dev enp37s0 proto kernel scope link src 192.168.0.61 metric 100
192.168.0.0/23 dev wlp36s0 proto kernel scope link src 192.168.0.102 metric 600
192.168.0.1 dev enp37s0 proto dhcp scope link src 192.168.0.61 metric 100
205.171.3.65 via 192.168.0.1 dev enp37s0 proto dhcp src 192.168.0.61 metric 100

and ip neigh

192.168.0.5 dev enp37s0 lladdr f0:18:98:85:f8:7f STALE
192.168.0.50 dev wlp36s0 lladdr f0:2f:4b:08:df:11 STALE
192.168.0.1 dev wlp36s0 lladdr 84:e8:92:8d:7f:10 REACHABLE
192.168.0.202 dev enp37s0 lladdr 34:7e:5c:f7:6c:f6 STALE
192.168.0.47 dev wlp36s0 lladdr e0:d4:64:e1:0a:0a STALE
192.168.0.50 dev enp37s0 lladdr f0:2f:4b:08:df:11 DELAY
192.168.0.200 dev wlp36s0 lladdr 58:ef:68:e9:02:a5 STALE
192.168.0.1 dev enp37s0 lladdr 84:e8:92:8d:7f:10 REACHABLE
192.168.0.38 dev wlp36s0 lladdr b8:e8:56:42:b1:80 STALE
192.168.0.55 dev wlp36s0 lladdr f4:d4:88:6a:99:f2 STALE
192.168.0.5 dev wlp36s0 lladdr f0:18:98:85:f8:7f STALE
192.168.0.202 dev wlp36s0 lladdr 34:7e:5c:f7:6c:f6 STALE
192.168.0.38 dev enp37s0 lladdr b8:e8:56:42:b1:80 REACHABLE
192.168.0.55 dev enp37s0 lladdr f4:d4:88:6a:99:f2 STALE
192.168.0.200 dev enp37s0 lladdr 58:ef:68:e9:02:a5 STALE
fe80::18a5:1285:aa20:5c0c dev enp37s0 lladdr 1c:b3:c9:35:ad:97 router STALE
fe80::86e8:92ff:fe8d:7f10 dev enp37s0 lladdr 84:e8:92:8d:7f:10 router REACHABLE

EDIT 2:

@netbat, thanks a bunch for looking at this stuff. I really appreciate it.

Here are the files from /etc/NetworkManager/system-connections/

:^).nmconnection (password removed for privacy):

[connection]
id=:^)
uuid=a48206d0-c23c-4634-b867-d743cec84e67
type=wifi
interface-name=wlp36s0
timestamp=1673334649

[wifi]
mode=infrastructure
ssid=:^)

[wifi-security]
key-mgmt=wpa-psk
psk=******

[ipv4]
method=auto

[ipv6]
addr-gen-mode=stable-privacy
method=auto

[proxy]

Wired connection 1.nmconnection:

[connection]
id=Wired connection 1
uuid=1ee423fe-8374-3689-b786-f46ea5ef193f
type=ethernet
autoconnect-priority=-999
interface-name=enp37s0
timestamp=1673410242

[ethernet]

[ipv4]
method=auto

[ipv6]
addr-gen-mode=stable-privacy
method=auto

[proxy]

I've disabled the wifi radio for the time being so I can just troubleshoot the ethernet connection. I should also say, you mentioned pinging known addresses like 8.8.8.8, but I've found that when the networking suddenly begins working (as tested in a browser) I'm still unable to ping or tracepath successfully to an IP outside of my home network.

The DHCP server on my router does show a listing for the mac address of my ethernet port listed to the same IP address that my device claims to be connected to.

For the two interfaces and two defaults issue, after disabling the wifi radio, I see that ip route now only shows one default route for the ethernet adapter.

Looking at the difference between the various ip commands when network is/isn't operational, the main differences I can see are in ip addr within the ethernet entry are:

working:

inet 192.168.0.61/23 brd 192.168.1.255 scope global dynamic enp37s0

not working:

inet 192.168.0.61/23 metric 100 brd 192.168.1.255 scope global dynamic enp37s0

and ip route working:

default via 192.168.0.1 dev enp37s0 proto dhcp metric 100 
192.168.0.0/23 dev enp37s0 proto kernel scope link src 192.168.0.61 
192.168.0.0/23 dev enp37s0 proto kernel scope link src 192.168.0.61 metric 100 
192.168.0.1 dev enp37s0 proto dhcp scope link src 192.168.0.61 metric 100 
205.171.3.65 via 192.168.0.1 dev enp37s0 proto dhcp src 192.168.0.61 metric 100 

vs not working

default via 192.168.0.1 dev enp37s0 proto dhcp src 192.168.0.61 metric 100 
192.168.0.0/23 dev enp37s0 proto kernel scope link src 192.168.0.61 metric 100 
192.168.0.1 dev enp37s0 proto dhcp scope link src 192.168.0.61 metric 100 
205.171.3.65 via 192.168.0.1 dev enp37s0 proto dhcp src 192.168.0.61 metric 100 

As for the netmask being /23 instead of the typical /24, I use that extra bit to distinguish smart devices on my network at a glance. I don't have enough devices to really warrant the whole extra bit but I like the convenience of X.X.0.X being a normal device and X.X.1.X being something I keep an eye on. I do have that configured at the router level, so all devices on the network respect that setting properly.


EDIT 3: After trying the changes suggested below, the connectivity does not improve unfortunately. It seems to be stuck in the same inconsistent state. What I have noticed after several reboots and re-connections to the network is one line in ip neigh goes from STALE to REACHABLE at roughly the same time the connection begins working and vice versa. Specifically this line:

fe80::86e8:92ff:fe8d:7f10 dev enp37s0 lladdr 84:e8:92:8d:7f:10 router STALE

everything else (other than timestamps) appears to remain the same, and this is the case whether or not I run the suggested ip route and ip addr modifications

Score:1
br flag

It looks like a problem with routing. Please attach here a list of command responses:

ip route
ip neigh

The first displays the routing table entries, the second shows the neighbors in the local network.

Perhaps a line with the following content is missing from the routing list (by ip route):

default via 192.168.0.1 dev wlp36s0 proto dhcp metric 100 

This is just an example. Your machine must have information about the address of the router through which to communicate out from LAN into the Internet. It is the so-called default gateway.


EDIT 1

Your other attached listings showed several problems.

Further analysis

Please enclose here the settings of your interfaces. They are in files in the directory /etc/NetworkManager/system-connections/. Summary listing is possible by command below (it is necessary to confirm the continuation to the next file with the space bar):

sudo more /etc/NetworkManager/system-connections/*

I believe that there is an error in your network in the form of a collision of two identical IP addresses, MAC addresses, two DHCP servers or something similar, which is manifested by alternating states when communication works and when it does not.

You should to perform the three diagnostic commands repeatedly to get a response in a state where the connection is working and then in a state where it does not work.

ip addr
ip route
ip neigh

By comparing the results and finding differences, we could move forward in finding the cause of the defect. At the same time in another terminal window on Ubuntu, you can have a ping e.g. on 8.8.8.8 to see if the connection out works or not.

Please also check the DHCP server settings on your router. Just check if there is a record for the MAC address of your Ubuntu and if there is a static IP address reservation for the given Ubuntu MAC eventually. The MAC address can be found using the ip addr command on an Ubuntu PC (search for link/ether clause).

Default gateway problem

You have not one, but three default gateways. This is wrong. Only in special circumstances is a different number used.

The item with the lowest metric number prevails when there are multiple routes for the same network. It is the Ethernet. Its metric is 100. But it looks your enp37s0 Ethernet interface is set up incorrectly by DHCP server, it should not have two default gateways (routes).

One gateway disappears when you turn off the Wi-Fi network interface.

It would be interesting to see the details of DHCP communication between the DHCP server and your Ubuntu. You can capture packets by using the tcpdump command. Details will be provided on request.

Two interfaces in the same time

I see that your Ubuntu PC has two interfaces that are connected to the same network 192.168.0.0/23 in the same time:

  • Ethernet enp37s0
  • Wi-Fi wlp36s0

This is not a good situation at all for diagnosing a problem. Please do tests with only one interface until the problem is resolved.

Question: Atypical netmask

Why do you use a netmask with a length of 23 bits, i.e. 255.255.254.0 instead of usual 24 bits? Is this intentional or inadvertent? I don't suppose you have, for example, 300 computers at home to use big network. It's entirely up to you, but the same mask must be set really on all devices. Then everything will work properly. Difference will cause a problem.


EDIT 2

Please try to configure the IP address and default route of the Ubuntu PC manually. When the setup works, we start analyzing DHCP. Do not worry, changes in manual settings using CLI remain only in RAM, after restarting the PC all changes disappears.

Status before changing, deleting old settings, status after change

ip addr
ip route

sudo ip route del default via 192.168.0.1 dev enp37s0
sudo ip route del 192.168.0.0/23 dev enp37s0 proto kernel scope link src 192.168.0.61 
sudo ip addr del 192.168.0.61/23 dev enp37s0

ip addr
ip route

Verify old route and old IP address are not present.

New settings, status after change

sudo ip addr add 192.168.0.61/23 dev enp37s0 brd 192.168.1.255
sudo ip route add default via 192.168.0.1 dev enp37s0

ip add
ip route
ping -c 3 192.168.0.1
ping -c 3 1.1.1.1

Does the new setting work? Is the status stable or will communication to the Internet be interrupted again after some time?


EDIT 3

It's time to analyze network packets. The following tcpdump command captures the three types of communication needed for parsing:

  • icmp
  • arp
  • DHCP

Diagnosis #1

in a state with a malfunctioning connection to the Internet.

Turn off the W-Fi interface if it is on. Open two terminal windows on Ubutnu PC.

Terminal 1:

Create a subdirectory to record captured packets in your home directory, and start the capture. A bad.pcap file is created for a state in which the connection to the Internet does not work.

mkdir ~/capture

sudo tcpdump -i enp37s0 "icmp or udp port 67 or udp port 68 or arp" -s 0 -w ~/capture/bad.pcap

Terminal 2:

Save the network status info:

cd ~/capture

ip add >> bad.txt
ip rou >> bad.txt
ip nei >> bad.txt

Verify connectivity and save the results to the same file state1.txt:

ping -c 3 192.168.0.1 | tee -a bad.txt
ping -c 3 1.1.1.1 | tee -a bad.txt

Release and renew dynamic IP address of the PC.

sudo dhclient -r enp37s0
sudo dhclient enp37s0

Verify connectivity again:

ping -c 3 192.168.0.1 | tee -a bad.txt
ping -c 3 1.1.1.1 | tee -a bad.txt

Go back to the first terminal window.

Terminal 1:

Stop the tcpdump command using Ctrl C.

Copy and save the bad.pcap and bad.txt files from your computer.

Diagnosis #2

in a state with a functional connection to the Internet.

Use ip addr to find out the name of the Ethernet interface, if it has changed, correct it in the following commands.

Terminal 1:

A good.pcap file is created for a state in which the connection to the Internet works, for instance after the Ubuntu is booted from Live USB Flash disk.

mkdir ~/capture

sudo tcpdump -i enp37s0 "icmp or udp port 67 or udp port 68 or arp" -s 0 -w ~/capture/good.pcap

Terminal 2:

Save the network status info:

cd ~/capture

ip add >> good.txt
ip rou >> good.txt
ip nei >> good.txt

Verify connectivity and save the results to the same file good.txt:

ping -c 3 192.168.0.1 | tee -a good.txt
ping -c 3 1.1.1.1 | tee -a good.txt

Release and renew dynamic IP address of the PC.

sudo dhclient -r enp37s0
sudo dhclient enp37s0

Verify connectivity again:

ping -c 3 192.168.0.1 | tee -a good.txt
ping -c 3 1.1.1.1 | tee -a good.txt

Go back to the first terminal window.

Terminal 1:

Stop the tcpdump command using Ctrl C.

Copy and save the good.pcap and good.txt files from your computer before you shut down the PC.

Final steps

Save all 4 files to a ZIP archive and make it available for detailed analysis. You can open and view the .pcap files using the Wireshark application. It is necessary to check not only the L3 layer, but also the L2 for any discrepancy in MAC addresses. Analysis of ARP and perhaps DHCP packets could tell us something. It is also need to pay attention to all kinds of ICMP messages, not just the echo request and the echo reply.

If you don't want to submit your diagnostic data publicly, email it to me.

Lucas Burns avatar
ag flag
I added the output of those commands to the original post, thanks for the help. I see in the `ip route` output several lines starting with `default` like the one you mentioned, but that second line is curious to me. `192.168.0.61` is the address of the ethernet port of this computer within my network, so that line almost reads like requests are somehow being looped back to this same computer instead of going to the router. Can you help me understand that line?
netbat avatar
br flag
I have added suggestions for further tests to my answer above.
Lucas Burns avatar
ag flag
Hey again, and thanks for you help poking through this. What would the invocation be for getting DHCP communication?
netbat avatar
br flag
I have added next suggestions for further tests to my answer above.
Lucas Burns avatar
ag flag
I've updated my post with the results of your previous suggestions
netbat avatar
br flag
Please, can you confirm that at the same time you have a functional connection between Ubuntu and you router, but connection to the outside via the router does not work? In EDIT 3, I added a procedure for capturing selected kinds of network data for more detailed analysis. It's up to you if you go for it. We cannot do more without packet analysis (except for personal presence on site).
netbat avatar
br flag
The line in the neighbor listing you mention refers to the IPv6 link-local address. I assume you don't have external IPv6 connectivity. In this case, the line and the displayed status (STALE/REACHABLE) serve only as an indicator of the ability of two network nodes to find each other in the local network and initiate communication with each other.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.