Skip to content

Instantly share code, notes, and snippets.

@fndari
Last active October 11, 2020 02:25
Show Gist options
  • Save fndari/7b23303638671d2f0ccb94756980dbe1 to your computer and use it in GitHub Desktop.
Save fndari/7b23303638671d2f0ccb94756980dbe1 to your computer and use it in GitHub Desktop.
Fix slow ethernet adapter speed on Linux

Fix slow ethernet adapter speed on Linux

Tested for:

  • Ubuntu 18.04/20.04
  • Lenovo X1 Carbon 6th gen ethernet dongle
  1. Download check-eth.sh to a directory on your $PATH, e.g. ~/.local/bin
  2. Make it executable with chmod +x ~/.local/bin/check-eth.sh
  3. Download check-eth.desktop to ~/.local/share/applications
  4. The script can be run both from the command line, or from the Gnome application launcher by entering "Check ethernet"
[Desktop Entry]
Name=Check ethernet speed and reload driver
Exec=gnome-terminal -e "check-eth.sh"
Terminal=false
Type=Application
Categories=Utility;Network
#!/bin/bash
set -euo pipefail
LAN_INTERFACE_NAME="enp0s31f6"
KERNEL_DRIVER_NAME="e1000e"
function check-eth-interface-speed {
local _interface="$LAN_INTERFACE_NAME"
echo "Checking speed for interface \"$_interface\"..."
sudo ethtool "$_interface" | grep -i Speed
}
function reload-kernel-driver {
local _modname="$KERNEL_DRIVER_NAME"
echo "Reloading kernel driver $_modname"
sudo modprobe --remove --verbose "$_modname"
sleep 2
sudo modprobe --verbose "$_modname"
}
function at-end {
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'
}
function main {
check-eth-interface-speed
reload-kernel-driver
sleep 5
check-eth-interface-speed
at-end
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment