Internet connection breaks, ping still works

Ubuntu Support Template

Ubuntu Version:
24.04 LTS

Desktop Environment (if applicable):
XFCE

Problem Description:
Every now and then my wired (!) internet access breaks. I can’t surf the internet or install packages via my package manager. But I CAN ping google.com.

The thing that helps is logging out and in. So nothing wrong w/ my hardware.

Relevant System Information:
Stopping my VPN (PIA) doesn’t help either.

What I’ve Tried:
Logging out and in: works.

When you connect to PIA (VPN) it changes your current DNS to their DNS. When you disconnect from PIA, it should revert back to your original setting. There is a file, /etc/openvpn/update-resolv-conf and the first few lines say that you need to add in your .ovpn

script-security 2 
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

resolvectl before vpn
Current DNS Server: 10.0.0.1

resolvectl after connect vpn
Current DNS Server: 192.168.1.1

resolvectl after disconnect vpn
Current DNS Server: 10.0.0.1

Your IP numbers will be different but you get the idea.

2 Likes

I would start with nslookup and traceroute command line tools.
The first will indicate if dns lookups (mapping site name to ip address) is working; the second will indiate if route to those sites is having issues.

1 Like

Thanks for those tips. Will do the next time I’m disconnected from the internet.

Have any of you an idea why the problem is gone after a re-login? Are certain services stopped if you don’t use ‘m for a long time?

Can you ping 8.8.8.8 when the ping fails?

Usually all user services are stopped, unless explicitly set otherwise, giving you a clean slate when logging back in, so that’s at least a clue. System services may shutdown when unused, there is a systemd setting for that, but I cannot say I’ve seen it being used. You can search for service units that have StopWhenUnneeded=:

sudo grep -ir StopWhenUnneeded= /{etc,run,usr/lib}/systemd

This needs sudo because /run/systemd may be inaccessible otherwise. You should also not search for yes, because that is not the only name for Boolean yes/no values in systemd.


Please use code blocks (</>) around all logs and other console/terminal output, ideally wrapped in a “Hide Details” element. See items 4 and 5 in the Posting Guide.

Optional WIP helper

If you are so inclined, I took it upon myself to provide a little helper script for that.

Thank you for the help/hints. This is the output of the command:

sudo grep -ir StopWhenUnneeded= /{etc,run,usr/lib}/systemd
/usr/lib/systemd/user/bluetooth.target:StopWhenUnneeded=yes
/usr/lib/systemd/user/printer.target:StopWhenUnneeded=yes
/usr/lib/systemd/user/graphical-session-pre.target:StopWhenUnneeded=yes
/usr/lib/systemd/user/graphical-session.target:StopWhenUnneeded=yes
/usr/lib/systemd/user/sound.target:StopWhenUnneeded=yes
/usr/lib/systemd/user/xdg-desktop-autostart.target:StopWhenUnneeded=yes
/usr/lib/systemd/user/smartcard.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/bluetooth.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/printer.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/blockdev@.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/brltty-udev.service:StopWhenUnneeded=true
/usr/lib/systemd/system/hybrid-sleep.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/sleep.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/suspend.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/systemd-journald@.socket:StopWhenUnneeded=yes
/usr/lib/systemd/system/hibernate.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/systemd-journald-varlink@.socket:StopWhenUnneeded=yes
/usr/lib/systemd/system/sound.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/suspend-then-hibernate.target:StopWhenUnneeded=yes
/usr/lib/systemd/system/user-.slice.d/10-defaults.conf:StopWhenUnneeded=yes
/usr/lib/systemd/system/user-runtime-dir@.service:StopWhenUnneeded=yes
/usr/lib/systemd/system/smartcard.target:StopWhenUnneeded=yes

Looks to me like there’s no network/internet service in that list…

1 Like

Yes, indeed, that’s pretty much what I am getting on my end. I think we can cross that off the list.

I don’t use PIA, or any VPN for that matter, so I can only give you more general advice on debugging network issues.

Can you tell us some more about how the error manifests? @pavlos’ suggestion seems to go in the right direction. It could be a DNS issue. That you can still ping google.com may be misleading, because that’s most likely in the DNS resolver’s cache. Next time this happens, you could do a ping first, to see if it’s still the same. Then flush the DNS cache and try again, it it doesn’t work anymore, it’s a DNS issue.

The somewhat tricky part is to figure out, what your resolver is, to reliably flush the correct cache. On a standard Ubuntu Desktop it should be systemd-resolved.

resolvectl status

should show if that’s the case and if so:

resolvectl flush-caches

will clear the DNS cache.

To add to @matt-rw’s suggestion. You can check the routing table of your machine with this

ip route

Ideally, you do a “before” snapshot, i.e. when it’s working alright, so we can compare it to “after”, when the failure happens.

But the route is only half the story, so here is the other one:

ip address

A before/after will go a long way here too.

@pavlos You wrote:

"
When you connect to PIA (VPN) it changes your current DNS to their DNS. When you disconnect from PIA, it should revert back to your original setting. There is a file, /etc/openvpn/update-resolv-conf and the first few lines say that you need to add in your .ovpn

script-security 2 
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

"

I disabled Snap and maybe that uninstalled certain stuff.

If I do a system wide find on my system then I can not find anything with “ovpn” or “update-resolv-conf” in the name. As you know I use a VPN from PIA (Private Internet Access): is it safe - or even a good idea - to install the package ‘openvpn’ via my package manager? Or will that “bite” my PIA VPN?

@peterwhite23 Thank you for the tips and the “redirection” to Pavlos’ reply. Next time if I lose internet connection I’ll flush the DNS cache before doing a ping. Good tip!

user@u24:~$ sudo find / -name "update-resolv*" -print
/etc/openvpn/update-resolv-conf
find: ‘/run/user/1000/gvfs’: Permission denied
find: ‘/run/user/1000/doc’: Permission denied

this is my ubuntu24. I have a /etc/ dir, a /etc/openvpn/ dir

user@u24:~$ ls /etc/openvpn/
client  server  update-resolv-conf

Manual Installation:

  1. Install OpenVPN: sudo apt-get install openvpn.
  2. Download the OpenVPN configuration files from PIA’s website.
  3. Connect using: sudo openvpn --config /path/to/file.ovpn

ovpn is a file extention.

Download pia-linux-3.7.2-08420.run and sh pia-linux-3.7.2-08420.run

installation output

user@u24:~$ sh pia-linux-3.7.2-08420.run
Verifying archive integrity… 100% MD5 checksums are OK. All good.
Uncompressing Private Internet Access 100%

=================================
Private Internet Access Installer

Installing PIA for x86_64, system is x86_64
[sudo] password for user:
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
libxkbcommon-x11-0 is already the newest version (1.6.0-1build1).
libxkbcommon-x11-0 set to manually installed.
libnl-3-200 is already the newest version (3.7.0-0.3build1.1).
libnl-3-200 set to manually installed.
libnl-route-3-200 is already the newest version (3.7.0-0.3build1.1).
libnl-route-3-200 set to manually installed.
iptables is already the newest version (1.8.10-3ubuntu2).
iptables set to manually installed.
psmisc is already the newest version (23.7-1build1).
psmisc set to manually installed.
libatomic1 is already the newest version (14.2.0-4ubuntu2~24.04.1).
libatomic1 set to manually installed.
The following additional packages will be installed:
libutempter0
Suggested packages:
xfonts-cyrillic
Recommended packages:
luit | x11-utils
The following NEW packages will be installed:
libutempter0 xterm
0 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.
Need to get 893 kB of archives.
After this operation, 2,556 kB of additional disk space will be used.
Get:1 Index of /ubuntu noble/main amd64 libutempter0 amd64 1.2.1-3build1 [9,606 B]
Get:2 Index of /ubuntu noble/universe amd64 xterm amd64 390-1ubuntu3 [883 kB]
Fetched 893 kB in 1s (717 kB/s)
Selecting previously unselected package libutempter0:amd64.
(Reading database … 197179 files and directories currently installed.)
Preparing to unpack …/libutempter0_1.2.1-3build1_amd64.deb …
Unpacking libutempter0:amd64 (1.2.1-3build1) …
Selecting previously unselected package xterm.
Preparing to unpack …/xterm_390-1ubuntu3_amd64.deb …
Unpacking xterm (390-1ubuntu3) …
Setting up libutempter0:amd64 (1.2.1-3build1) …
Setting up xterm (390-1ubuntu3) …
Processing triggers for hicolor-icon-theme (0.17-2) …
Processing triggers for gnome-menus (3.36.0-1.1ubuntu3) …
Processing triggers for libc-bin (2.39-0ubuntu8.7) …
Processing triggers for man-db (2.12.0-4build2) …
Processing triggers for desktop-file-utils (0.27-2build1) …
:check_mark: Installed packages
:check_mark: Added group piavpn
:check_mark: Added group piahnsd
:check_mark: Copied Private Internet Access files
:check_mark: Allow non-root /opt/piavpn/bin/pia-unbound to bind to privileged ports
:check_mark: Created var folder
:check_mark: Installed icon
:check_mark: Created desktop entry
:check_mark: Set wgpia interface to be unmanaged
:check_mark: Created piavpn service
Created symlink /etc/systemd/system/multi-user.target.wants/piavpn.service → /etc/systemd/system/piavpn.service.
:check_mark: Started piavpn service
user@u24:~$

PIA installs in /opt/piavpn

user@u24:~$ ls /opt/piavpn/
bin  etc  lib  plugins  qml  share  var

Not logging out but restarting daemons in user space one by one beginning with vpn client and testing connectivity after each might help finding the one that is breaking your connection.

1 Like

This may be a stupid question, but how do I determine all running daemons on my system (well, the ones that affect my (inter)net connection)?

systemctl --no-pager --user list-units --type=service --state=running brings up a list of all currently running user daemons. To see not running daemons just drop –state=running from above command.
I guess you have to look up services in this list to find those probably involved in your troubles.


It’s no stupid question. I’m learning much on Ubuntu/Linux myself by trying to help on Ubuntu discourse. And I think my English is slowly improving too.

1 Like

Thanks for the help. Will do if my i’net connection fails. I’ve learned that one can restart a service/daemon by (example):

systemctl restart piavpn.service
1 Like