Activation of network connection failed - fixes when reboot from windows

Solution 1:

Link speed

Your ethernet card is capable of 1Gb speed, but is only being used at 100Mb speed. This usually indicates either a cable problem, or that some network device like an ethernet hub/switch/router isn't providing 1G speed. First, check that you're using cat 5e or cat 6 ethernet cables.

sudo lshw -C network

size: 100Mbit/s
capacity: 1Gbit/s

ethernet driver

The r8169 driver is known to have some problems. Install this driver and see if things improve.

sudo apt update

sudo apt install dkms r8168-dkms

reboot

MSI interrupt problem

Some r816x ethernet cards don't handle MSI/MSIX interrupts properly. If needed, we may need to implement a patch to work around the problem. Information provided when needed. Show me:

lspci -nn | grep -i ethernet

05:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 0c)

Here's the required patch. Instructions are in the script. Follow closely.

# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1779817

# filename: r8169_disable_msi

# Drop it in /etc/initramfs-tools/scripts/init-top and chmod a+x it. Add 'r8169_disable_msi'
# to your kernel command line (/etc/default/grub, GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
# usually.) 

# Remember to update-initramfs and update-grub as necessary.

# sudo update-initramfs -c -k $(uname -r)
# sudo update-grub
# reboot

# For the moment it disables MSI on everything with the ID 0x10ec:0x8168, as there seems to
# be no way to get the MAC version from userspace - and certainly not before the driver is
# loaded. Other PCI IDs may need adding..

PREREQ=""
prereqs()
{
    echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
    prereqs
    exit 0
    ;;
esac

disable_msi () {
    for i in /sys/bus/pci/devices/*; do 
        if [ $(cat $i/vendor) = "0x10ec" -a $(cat $i/device) = "0x8168" ]; then
            echo 0 >$i/msi_bus
        fi
    done
}

for x in $(cat /proc/cmdline); do
        case ${x} in
        r8169_disable_msi)
        disable_msi
        break
                ;;
        esac
done