Slow wifi speeds temporarily on boot

╰─λ systemctl status network-restart.service
○ network-restart.service - Network Restart Service
Loaded: bad-setting (Reason: Unit network-restart.service has a bad unit file setting.)
Active: inactive (dead)
[🧱] × cat /etc/systemd/system/network-restart.service
File: /etc/systemd/system/network-restart.service
#/etc/systemd/system/network-restart.service
#sudo systemctl enable network-restart.service
#sudo systemctl start network-restart.service
#systemctl status network-restart.service

[Unit]
Description=Network Restart Service
After=network.target multi-user.target sddm.service
Requires=sddm.service
StopWhenUnneeded=yes

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
Restart=always
RestartSec=3
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking off'
ExecStart=/usr/bin/sleep 1
ExecStart=/usr/bin/systemctl stop NetworkManager
ExecStart=/usr/bin/ip link set wlp6s0  down
ExecStart=/usr/bin/modprobe -r  rtl8192ee
ExecStart=/usr/bin/sleep 5
ExecStart=/usr/bin/modprobe rtl8192ee
ExecStart=/usr/bin/sleep 3
ExecStart=/usr/bin/ip link set wlp6s0 up
ExecStart=/usr/bin/sleep 2
ExecStart=/usr/bin/systemctl start NetworkManager
ExecStart=/usr/bin/sleep 1
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking on'
ExecStart=/usr/bin/sleep 1
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi off'
ExecStart=/usr/bin/sleep 1
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi on'

[Install]
WantedBy=multi-user.target

Remove the above two lines from the service file, or you can simply comment them out as below:

#Restart=always
#RestartSec=3

Save your changes and then restart.

After restarting, again run the following command and post the output:

systemctl status network-restart.service 

It is often difficult to troubleshoot a service remotely as it can take a lot of time testing different variations. This service should work though, as I’ve written very similar working versions many times in the past.

If the above changes don’t help then try the changes below.

Alter the following section:

Ammend it as follows:

[Unit]
Description=Network Restart Service
Wants=network-online.target
After=network-online.target
StopWhenUnneeded=yes

Save the changes, then restart.


If the service begins to function correctly, but you can’t live with the startup delays then you can comment out or reduce the time intervals of the sleep units.

Example:

#/etc/systemd/system/network-restart.service
#sudo systemctl enable network-restart.service
#sudo systemctl start network-restart.service
#systemctl status network-restart.service

[Unit]
Description=Network Restart Service
Wants=network-online.target
After=network-online.target
StopWhenUnneeded=yes

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
#Restart=always 
#RestartSec=3
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking off'
#ExecStart=/usr/bin/sleep 1
ExecStart=/usr/bin/systemctl stop NetworkManager
ExecStart=/usr/bin/ip link set wlp6s0  down
ExecStart=/usr/bin/modprobe -r  rtl8192ee
ExecStart=/usr/bin/sleep 2
ExecStart=/usr/bin/modprobe rtl8192ee
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/ip link set wlp6s0 up
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/systemctl start NetworkManager
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking on'
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi off'
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi on'

[Install]
WantedBy=multi-user.target

As I’ve already mentioned several times, you can eliminate the sleep units entirely, but then the service may not execute correctly.

Post the results of running the status command after making changes and restarting.

4 Likes
[🧱] × systemctl status network-restart.service
● network-restart.service - Network Restart Service
Loaded: loaded (/etc/systemd/system/network-restart.service; enabled; preset: disabled)
Active: active (exited) since Wed 2023-02-08 15:01:38 AEDT; 1min 40s ago
Process: 635 ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc nmcli networking off (code=exited, status=0/SUCCESS)
Process: 1237 ExecStart=/usr/bin/sleep 1 (code=exited, status=0/SUCCESS)
Process: 1281 ExecStart=/usr/bin/systemctl stop NetworkManager (code=exited, status=0/SUCCESS)
Process: 1283 ExecStart=/usr/bin/ip link set wlp6s0 down (code=exited, status=0/SUCCESS)
Process: 1284 ExecStart=/usr/bin/modprobe -r rtl8192ee (code=exited, status=0/SUCCESS)
Process: 1296 ExecStart=/usr/bin/sleep 5 (code=exited, status=0/SUCCESS)
Process: 2162 ExecStart=/usr/bin/modprobe rtl8192ee (code=exited, status=0/SUCCESS)
Process: 2165 ExecStart=/usr/bin/sleep 3 (code=exited, status=0/SUCCESS)
Process: 2313 ExecStart=/usr/bin/ip link set wlp6s0 up (code=exited, status=0/SUCCESS)
Process: 2316 ExecStart=/usr/bin/sleep 2 (code=exited, status=0/SUCCESS)
Process: 2319 ExecStart=/usr/bin/systemctl start NetworkManager (code=exited, status=0/SUCCESS)
Process: 2323 ExecStart=/usr/bin/sleep 1 (code=exited, status=0/SUCCESS)
Process: 2477 ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc nmcli networking on (code=exited, status=0/SUCCESS)
Process: 2622 ExecStart=/usr/bin/sleep 1 (code=exited, status=0/SUCCESS)
Process: 2845 ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc nmcli r wifi off (code=exited, status=0/SUCCESS)
Process: 2900 ExecStart=/usr/bin/sleep 1 (code=exited, status=0/SUCCESS)
Process: 2901 ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc nmcli r wifi on (code=exited, status=0/SUCCESS)
Main PID: 2901 (code=exited, status=0/SUCCESS)
CPU: 1.682s

Feb 08 15:01:33 garuda-b450mh sudo[2477]:     root : PWD=/ ; USER=root ; COMMAND=/bin/bash -lc nmcli networking on
Feb 08 15:01:33 garuda-b450mh sudo[2477]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Feb 08 15:01:34 garuda-b450mh sudo[2477]: pam_unix(sudo:session): session closed for user root
Feb 08 15:01:35 garuda-b450mh sudo[2845]:     root : PWD=/ ; USER=root ; COMMAND=/bin/bash -lc nmcli r wifi off
Feb 08 15:01:35 garuda-b450mh sudo[2845]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Feb 08 15:01:36 garuda-b450mh sudo[2845]: pam_unix(sudo:session): session closed for user root
Feb 08 15:01:37 garuda-b450mh sudo[2901]:     root : PWD=/ ; USER=root ; COMMAND=/bin/bash -lc nmcli r wifi on
Feb 08 15:01:37 garuda-b450mh sudo[2901]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Feb 08 15:01:38 garuda-b450mh sudo[2901]: pam_unix(sudo:session): session closed for user root
Feb 08 15:01:38 garuda-b450mh systemd[1]: Finished Network Restart Service.

this may have to do with the script but before i followed your changes in this post, there were no networks unavailable for some reason.

Sorry, but I’m having a hard time figuring out what exactly you have done, and the results. Perhaps we have a language issue here, because I’m left confused by what you are trying to say.

Apparently the first version of my service (not a script), was inoperable from the looks of its status output (bad-setting). It appears that after modifying the original version of the service it was executing properly. However, you have not exactly provided any detailed information on what changes you made to the service. A 15 second delay before the connection is expected, as it appears that you did not reduce or eliminate the sleep units in the service. My example I posted previously showed you how to do this. Yet it appears that you did not implement my proposed reductions to the sleep times in the service.

I will post again, the example of how to reduce the connection delay after login:

#/etc/systemd/system/network-restart.service
#sudo systemctl enable network-restart.service
#sudo systemctl start network-restart.service
#systemctl status network-restart.service

[Unit]
Description=Network Restart Service
Wants=network-online.target
After=network-online.target
StopWhenUnneeded=yes

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
#Restart=always 
#RestartSec=3
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking off'
#ExecStart=/usr/bin/sleep 1
ExecStart=/usr/bin/systemctl stop NetworkManager
ExecStart=/usr/bin/ip link set wlp6s0  down
ExecStart=/usr/bin/modprobe -r  rtl8192ee
ExecStart=/usr/bin/sleep 2
ExecStart=/usr/bin/modprobe rtl8192ee
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/ip link set wlp6s0 up
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/systemctl start NetworkManager
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking on'
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi off'
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi on'

[Install]
WantedBy=multi-user.target

I am not at your place looking over your shoulder while you perform modifications to the service. The only way I can know what changes you have made is from you posting any modifications you have made to the service file on the forum. I have already given you the command required to display/post the service file’s content.

Type the following command to display the service’s content:

cat /etc/systemd/system/network-restart.service

Then post the output of the above cat command after making any modifications to the service file. Also be sure to post the service’s status after making any changes to the service, (and rebooting).

systemctl status network-restart.service

Sorry my friend, but you need put more effort into providing clear ad understandable information if you desire assistance and want your issues resolved.

4 Likes

At first I modified the delay times of your script to take less time, but after the network issue was still present, I decided to put it back to the original 15 seconds to see if that would change anything.

systemctl status network-restart.service

Doing the above command now shows that the script is active after removing the two lines on the script that you advised me to.

Sorry for the misunderstanding.

As for an update on the wifi connectivity issues:

Wifi connectivity still struggles when first booting up my computer, even after the initial 15 seconds and with an active script and following all of your advice.

I also have noticed that my wifi speeds are significantly slower. Before my network speeds were roughly at 50Mbps, and now it is at 20-25Mbps.

For some reason when I put my computer to sleep and woke it back up, there was no wifi icon at all in the widgets area. There was also no wifi connection (doing ping archlinux.org did nothing). Because of this I tried restarting numerous times and even booting to Windows, but for some reason it never worked.

It only started working again after I fully shut down and powered on my computer.

This is some very weird and annoying behaviour.

Does your script affect virtual machines? Because both virtual machines on my computer are no longer having an internet connection.

Sorry to have to repeat this, but:

I posted the above request for info 9 days ago and still you have not supplied your revised information that I requested. It is near impossible to remotely troubleshoot a service unless the one requesting the support fully complies with all requests. Please post both the cat and status outputs again.

2 Likes

cat command:

#/etc/systemd/system/network-restart.service
#sudo systemctl enable network-restart.service
#sudo systemctl start network-restart.service
#systemctl status network-restart.service

[Unit]
Description=Network Restart Service
Wants=network-online.target
After=network-online.target
StopWhenUnneeded=yes

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
#Restart=always
#RestartSec=3
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking off'
#ExecStart=/usr/bin/sleep 1
ExecStart=/usr/bin/systemctl stop NetworkManager
ExecStart=/usr/bin/ip link set wlp6s0  down
ExecStart=/usr/bin/modprobe -r  rtl8192ee
ExecStart=/usr/bin/sleep 2
ExecStart=/usr/bin/modprobe rtl8192ee
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/ip link set wlp6s0 up
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/systemctl start NetworkManager
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking on'
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi off'
ExecStart=/usr/bin/sleep .5
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi on'

[Install]
WantedBy=multi-user.target

systemctl:

○ network-restart.service - Network Restart Service
Loaded: loaded (/etc/systemd/system/network-restart.service; enabled; preset: disabled)
Active: inactive (dead)

Somehow systemctl says that the script is active:

● network-restart.service - Network Restart Service
Loaded: loaded (/etc/systemd/system/network-restart.service; enabled; preset: disabled)
Active: active (exited) since Sun 2023-02-19 10:29:13 AEDT; 48min ago
Process: 3737 ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc nmcli networking off (code=exited, status=0/SUCCESS)
Process: 3759 ExecStart=/usr/bin/systemctl stop NetworkManager (code=exited, status=0/SUCCESS)
Process: 3762 ExecStart=/usr/bin/ip link set wlp6s0 down (code=exited, status=0/SUCCESS)
Process: 3763 ExecStart=/usr/bin/modprobe -r rtl8192ee (code=exited, status=0/SUCCESS)
Process: 3770 ExecStart=/usr/bin/sleep 2 (code=exited, status=0/SUCCESS)
Process: 3771 ExecStart=/usr/bin/modprobe rtl8192ee (code=exited, status=0/SUCCESS)
Process: 3772 ExecStart=/usr/bin/sleep .5 (code=exited, status=0/SUCCESS)
Process: 3775 ExecStart=/usr/bin/ip link set wlp6s0 up (code=exited, status=0/SUCCESS)
Process: 3779 ExecStart=/usr/bin/sleep .5 (code=exited, status=0/SUCCESS)
Process: 3780 ExecStart=/usr/bin/systemctl start NetworkManager (code=exited, status=0/SUCCESS)
Process: 3784 ExecStart=/usr/bin/sleep .5 (code=exited, status=0/SUCCESS)
Process: 3790 ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc nmcli networking on (code=exited, status=0/SUCCESS)
Process: 3802 ExecStart=/usr/bin/sleep .5 (code=exited, status=0/SUCCESS)
Process: 3805 ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc nmcli r wifi off (code=exited, status=0/SUCCESS)
Process: 3815 ExecStart=/usr/bin/sleep .5 (code=exited, status=0/SUCCESS)
Process: 3816 ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc nmcli r wifi on (code=exited, status=0/SUCCESS)
Main PID: 3816 (code=exited, status=0/SUCCESS)
CPU: 1.060s

Feb 19 10:29:10 garuda-b450mh sudo[3790]:     root : PWD=/ ; USER=root ; COMMAND=/bin/bash -lc 'nmcli networking on'
Feb 19 10:29:10 garuda-b450mh sudo[3790]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Feb 19 10:29:11 garuda-b450mh sudo[3790]: pam_unix(sudo:session): session closed for user root
Feb 19 10:29:12 garuda-b450mh sudo[3805]:     root : PWD=/ ; USER=root ; COMMAND=/bin/bash -lc 'nmcli r wifi off'
Feb 19 10:29:12 garuda-b450mh sudo[3805]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Feb 19 10:29:12 garuda-b450mh sudo[3805]: pam_unix(sudo:session): session closed for user root
Feb 19 10:29:12 garuda-b450mh sudo[3816]:     root : PWD=/ ; USER=root ; COMMAND=/bin/bash -lc 'nmcli r wifi on'
Feb 19 10:29:12 garuda-b450mh sudo[3816]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Feb 19 10:29:13 garuda-b450mh sudo[3816]: pam_unix(sudo:session): session closed for user root
Feb 19 10:29:13 garuda-b450mh systemd[1]: Finished Network Restart Service.

The script has been active for a few days now. However, I am still getting connectivity issues after the script has finished.

For example, my network still has connection issues after the initial script for some reason. It briefly disconnects and reconnects.

Also, your script has done something that has affected the wifi connection on my virtual machine. I can no longer connect to the internet on my VM.

I hope this makes the current situation more understandable for you.

I'm not really sure where you can go at this point for a resolution.

I would suggest trying the following:

Test further kernels such as linux and linux-hardened.

Disable MAC Address randomization and then reboot your router and computer.

Try setting a different DNS server through the Garuda utilities.

Try setting a static IP address in Network Manager or in your router's configuration.

Unfortunately I cannot help you with issues on your virtual machines as I only install to bare metal.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.