# Ethernet connection is 2 times slower on Gentoo than on Win

## UltraGreed

Hello, guys, I have a problem, which I've been trying to fix for several days already. 

So, I am dualbooting windows 10 and Gentoo Linux on two different drives. 

When I use speedtest.net on windows it gives me ~60 Mbps both download and upload, but on Gentoo I have only ~30 Mbps both download and upload. speedtest-cli gives the same result. 

Steam download speed is about two times slower on Gentoo, too. Please, give me some ideas what to do.

Things I've tried already: 

1. switched to r8168 driver from r8169 

2. disabled ipv6 with editing /etc/sysctl.conf

3. changed mtu from 1500 to 1492/4000/9000

4. disabled flow-control with mii-tool

There are some my Linux network configuration info:

```
 ~$ dmesg | grep enp6s0

[    5.016092] r8168 0000:06:00.0 enp6s0: renamed from eth0

[    9.539711] enp6s0: 0xffffa708c0031000, 70:4d:7b:65:72:15, IRQ 129

[   11.969028] r8168: enp6s0: link up

[   11.969314] IPv6: ADDRCONF(NETDEV_CHANGE): enp6s0: link becomes ready
```

```
 ~$ lspci -s 06:00 -v

06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)

   Subsystem: ASUSTeK Computer Inc. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller

   Flags: bus master, fast devsel, latency 0, IRQ 129

   I/O ports at d000 [size=256]

   Memory at f7204000 (64-bit, non-prefetchable) [size=4K]

   Memory at f7200000 (64-bit, non-prefetchable) [size=16K]

   Capabilities: <access denied>

   Kernel driver in use: r8168

   Kernel modules: r8168
```

```
~$ ifconfig -a

enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.100  netmask 255.255.255.0  broadcast 255.255.255.255

        inet6 fe80::b380:42e0:6cd9:a433  prefixlen 64  scopeid 0x20<link>

        ether 70:4d:7b:65:72:15  txqueuelen 1000  (Ethernet)

        RX packets 476718  bytes 222698032 (212.3 MiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 321008  bytes 82362995 (78.5 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        device interrupt 129  base 0x1000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

sit0: flags=128<NOARP>  mtu 1480

        sit  txqueuelen 1000  (IPv6-in-IPv4)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

```

```
~$ ethtool enp6s0

Settings for enp6s0:

   Supported ports: [ TP ]

   Supported link modes:   10baseT/Half 10baseT/Full 

                           100baseT/Half 100baseT/Full 

                           1000baseT/Full 

   Supported pause frame use: Symmetric Receive-only

   Supports auto-negotiation: Yes

   Supported FEC modes: Not reported

   Advertised link modes:  10baseT/Half 10baseT/Full 

                           100baseT/Half 100baseT/Full 

                           1000baseT/Full 

   Advertised pause frame use: Symmetric Receive-only

   Advertised auto-negotiation: Yes

   Advertised FEC modes: Not reported

   Link partner advertised link modes:  10baseT/Half 10baseT/Full 

                                        100baseT/Half 100baseT/Full 

   Link partner advertised pause frame use: Symmetric

   Link partner advertised auto-negotiation: Yes

   Link partner advertised FEC modes: Not reported

   Speed: 100Mb/s

   Duplex: Full

   Port: Twisted Pair

   PHYAD: 0

   Transceiver: internal

   Auto-negotiation: on

   MDI-X: Unknown

   Current message level: 0x00000033 (51)

                drv probe ifdown ifup

   Link detected: yes

```

```
~$ ip link show

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000

    link/sit 0.0.0.0 brd 0.0.0.0

3: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000

    link/ether 70:4d:7b:65:72:15 brd ff:ff:ff:ff:ff:ff

```

Windows network configuration info:

```
ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : DESKTOP-6M5NNF6

   Primary Dns Suffix  . . . . . . . :

   Node Type . . . . . . . . . . . . : Hybrid

   IP Routing Enabled. . . . . . . . : No

   WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . :

   Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller

   Physical Address. . . . . . . . . : 70-4D-7B-65-72-15

   DHCP Enabled. . . . . . . . . . . : Yes

   Autoconfiguration Enabled . . . . : Yes

   Link-local IPv6 Address . . . . . : fe80::16a:eee0:bb00:3c30%2(Preferred)

   IPv4 Address. . . . . . . . . . . : 192.168.1.100(Preferred)

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   Lease Obtained. . . . . . . . . . : 14 декабря 2020 г. 2:43:48

   Lease Expires . . . . . . . . . . : 14 декабря 2020 г. 4:43:48

   Default Gateway . . . . . . . . . : 192.168.1.1

   DHCP Server . . . . . . . . . . . : 192.168.1.1

   DHCPv6 IAID . . . . . . . . . . . : 108023163

   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-26-A5-FC-DA-70-4D-7B-65-72-15

   DNS Servers . . . . . . . . . . . : 192.168.158.135

                                       192.168.158.136

   NetBIOS over Tcpip. . . . . . . . : Enabled
```

Please, tell me if I should post any additional info. Thanks for your attention.

----------

## guitou

Hello.

Looks like your adapter is limited to 100M in Linux. If on a GB network, this might be the cause of your slower rates.

Then about further investigation, I would check if some firmware is required, installed, properly loaded...

++

Gi)

----------

## mike155

It looks like link auto-negotiation doesn't work:

```
Link partner advertised link modes:  10baseT/Half 10baseT/Full

                                     100baseT/Half 100baseT/Full 
```

1000baseT/Full is missing. Why? Or does your switch/router support only 100 MBit/s?

----------

## UltraGreed

Hello, thank you for your answers!

mike155, 

I'm not sure if my router supports 1000 MBit/s connection or not, but anyways My usual speed is limited to 60 MBit/s. If it still matters, I can check my router model and search if it supports fast connection or not. Also, this auto-negotiation thing, can it still be related to problem? If so, what can I do?

guitou, 

As I said above, My usual speed is much slower, than 100 MBit/s, so I don't think this limitation is related to problem. I'm not sure about firmware. I know that I need r8168-driver and it is installed, but that's it. I'm not sure how to check if there is any other drivers. Unfortunately, there are only drivers for windows on manufacturer's site. And I wasn't able to find any related to my card and Linux info, except for r8168 driver.

Thanks again, your help is really appreciated.

----------

## UltraGreed

Hello again!

I've checked my router.

They say wired speed it can give is limited to 100 MBit/s.

----------

## guitou

Hi.

If missing firmware, I guess package you are looking for is simply linux-firmware.

++

Gi)

----------

## Tony0945

 *UltraGreed wrote:*   

> Hello again!
> 
> I've checked my router.
> 
> They say wired speed it can give is limited to 100 MBit/s.

 

Capital B, so it should be Gigabit?  I've been using this router for several months. It's great. If your current router is a "wifi router" just put it in AP mode and use a real standalone router. That makes trouble shooting easier.

Ubiquiti EdgeRouter X ER-X

I paid a lot less elsewhere for new, not used. Shop around.  The OS is Linux-derived. Many people complain about the "opaque" and "arcane" command line interface. That interface is Linux shell. You should have no problems.  And it does have a handy GUI for setup.

----------

## NeddySeagoon

UltraGreed,

With the r8169 driver in the kernel, what does dmesg say about firmware?

The RTL8169 range of chips can have firmware for all sorts of reasons but they operate without it.

The r8168 driven should be avoided if at all possible.

The 100Mb/sec link speed should provide the 60Mb/sec that you are expecting.

Well, it does with Windows, so while its interesting, its low down the list of things to poke at.

----------

## UltraGreed

 *Tony0945 wrote:*   

> 
> 
> Capital B, so it should be Gigabit?

 

Sorry, I meant Mbit, not MByte.

 *NeddySeagoon wrote:*   

> 
> 
> With the r8169 driver in the kernel, what does dmesg say about firmware? 
> 
> 

 

I used to use r8169, but downgraded to r8168 as they say it is more stable.

Though, I will try r8169 again and upload dmesg info.

What exactly should I upload? Would 

```
dmesg | grep r8169
```

 be enough?

----------

## UltraGreed

```
 dmesg | grep r8169

[    0.385482] r8169 0000:06:00.0: can't disable ASPM; OS doesn't have ASPM control

[    0.391641] libphy: r8169: probed

[    0.394069] r8169 0000:06:00.0 eth0: RTL8168h/8111h, 70:4d:7b:65:72:15, XID 541, IRQ 128

[    0.395604] r8169 0000:06:00.0 eth0: jumbo features [frames: 9200 bytes, tx checksumming: ko]

[    5.806631] r8169 0000:06:00.0 enp6s0: renamed from eth0

[   11.717232] Generic FE-GE Realtek PHY r8169-600:00: attached PHY driver [Generic FE-GE Realtek PHY] (mii_bus:phy_addr=r8169-600:00, irq=IGNORE)

[   11.806760] r8169 0000:06:00.0 enp6s0: Link is Down

[   13.585845] r8169 0000:06:00.0 enp6s0: Link is Up - 100Mbps/Full - flow control rx/tx

```

----------

## NeddySeagoon

UltraGreed,

Read between the lines you posted an look for pauses and errors related to firmware loading.

When in time does root get mounted ?

You could use wgetpaste to put the whole of dmesg onto a pastbin, then post the link.

That way we can spot what is missing and should be there as opposed to working only with what is actually there.

----------

## Tony0945

I have this on a fairly recent MSI motherboard.

```
$  dmesg | grep r8169

[    0.000000] libphy: r8169: probed

[    0.000000] r8169 0000:19:00.0 eth0: RTL8168h/8111h, 30:9c:23:1b:42:51, XID 541, IRQ 45

[    0.000000] r8169 0000:19:00.0 eth0: jumbo features [frames: 9200 bytes, tx checksumming: ko]

[    0.000000] Generic FE-GE Realtek PHY r8169-1900:00: attached PHY driver [Generic FE-GE Realtek PHY] (mii_bus:phy_addr=r8169-1900:00, irq=IGNORE)

[    0.000000] r8169 0000:19:00.0 eth0: Link is Down

[    0.000000] r8169 0000:19:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx

```

I don't have 

```
 can't disable ASPM; OS doesn't have ASPM control
```

```
tony@MSI ~ $ uname -a

Linux MSI 5.4.80-gentoo-r1 #1 SMP Sun Nov 29 13:40:43 CST 2020 x86_64 AMD Ryzen 7 2700X Eight-Core Processor AuthenticAMD GNU/Linux
```

My kernel config: https://dpaste.com/EVF7S26FL

----------

## UltraGreed

Sorry for delay. Here is my full dmesg output: https://pastebin.com/gMV5aKn9

----------

## Tony0945

I wonder if these are confusing the software:

```
[    0.372129] e100: Intel(R) PRO/100 Network Driver, 3.5.24-k2-NAPI

[    0.373533] e100: Copyright(c) 1999-2006 Intel Corporation

[    0.374931] e1000: Intel(R) PRO/1000 Network Driver - version 7.3.21-k8-NAPI

[    0.376352] e1000: Copyright (c) 1999-2006 Intel Corporation.

[    0.377796] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k

[ 0.379242] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
```

Try blacklisting them. Just a guess.

EDIT:

```
    0.389920] r8169 0000:06:00.0 eth0: RTL8168h/8111h, 70:4d:7b:65:72:15, XID 541, IRQ 128

[    0.391457] r8169 0000:06:00.0 eth0: jumbo features [frames: 9200 bytes, tx checksumming: ko]

[    5.761964] r8168: loading out-of-tree module taints kernel.

[    5.902741] r8169 0000:06:00.0 enp6s0: renamed from eth0

```

 Also loading both R8168 and R8169?  A big No-No. Blacklist the one of them or rebuild the kernel without it. 

Each one thinks it has exclusive control of the hardware?

----------

## nvaert1986

It might sound silly, but try using the driver provided by Realtek. Up until a few months ago I was also having issues with my Realtek NIC that was in my Lenovo ThinkPad Docking station. Using the driver provided by Realtek resolved the issues. Eventually the issues I encountered were resolved in the 5.8 kernel series. I've used the drivers mentioned down below with the gentoo-sources-5.4.x series and they never gave me any issues.

For PCI-E see: https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software

For USB see: https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-usb-3-0-software

Simply download, extract, go into the directory using the terminal, switch to root using su or sudo -s and run the default ./configure then make and then make install.

NOTE: You'll have to re-compile the driver manually with every kernel update.

Another option is to try and use a more recent kernel. That could resolve your issues too.

Unfortunately you do not have a choice when it comes to laptops and such (as the NIC is integrated, and many USB NIC's use Realtek), but I'm not a big Realtek fan myself. I've always had some stability issues with their NIC's for some reason. Whenever I buy a laptop or PC, I always try to look for a machine with a Intel based adapter (preferrable igb based; e1000e has their share of issues too; though less so than Realtek) as it's way more stable than Realtek.

P.S.: I just read that enabling the Boot ROM in the BIOS / UEFI screen, might also help. Please see: https://bugzilla.kernel.org/show_bug.cgi?id=202275 for details where other users have similar issues where Realtek hardware is detected as 100Mbit only.

----------

## Tony0945

 *nvaert1986 wrote:*   

> I've always had some stability issues with their NIC's for some reason.

 

Realtek doesn't actually make chips like Intel. The make designs that the mobo manufacturer farms out to a low bidder. I'm sure that's part of the problem. Also the name, say R8169 is a design that needs to be interfaced with the other mobo chips, this can be different on each implementation, even from the same mobo manufacturer. This can lead to bugs also. It's probably less of a problem where the manufactirer stays close to an AMD or Intel reference motherboard design which they do disseminate in an effort to win bids from mobo companies.

----------

## UltraGreed

I've just tried to connect my Ethernet cable directly into my pc, without router, and a test ended with a result in ~90mbps! I didn't even knew my internet is so fast! So it seems like router problem. Probably I should buy new one?

----------

## UltraGreed

But it still is strange: why do I have 60 Mbps on Win and only 30 Mbps on Linux? Probably my router has bad Linux-support? Is it even possible?

----------

## UltraGreed

Everything works with new router. Anyways, thanks you, guys, for all your advice. I think the issue was solved.

----------

## turtles

May be a little late but I have had a similar issue on every Linux box I admin.

I only have IPV4 LAN networks, and it has to do with how either Glibc or the kernel itself prioritizes IPV6 DNS lookups.

its easy to spot by using tcpdump and running a script to check for IPV6 'AAAA' lookups timing out.

I used to remove IPV6 from the kernel but these days that breaks some browsers like chrome, (which I still don't get why they need in an ipv4 only network).

Adding 

```
precedence ::ffff:0:0/96  100
```

to /etc/gai.conf takes care of slow DNS on for me.

Note this is not just Gentoo its all Linux distros.

----------

