Ubuntu – How to stop the ethernet network connection from dropping

11.04networkingrealtek

My ethernet-based network connection doesn't stay up consistently. I'm running a ping against the gateway and it will:

  • Work for a minute
  • Freeze, time out, or give multi-second response times
  • Repeat

If it's stuck and I disable/enable networking through the network manager applet everything will work fine again for a minute. After 280 packets transmitted I'm getting 41% packet loss. I've tried a different cable and connection to the gateway but this had no effect. The distance to the gateway is just about 3 feet.

Seems to work fine if I switch over to Windows, but Ubuntu is my main OS and I can't even use it right now as I depend on the network.

My setup…

  • OS: Ubuntu 11.04, dual-booting Windows 7
  • Mobo: Gigabyte Z68X-UD4-B3
  • CPU: Intel Core i7 2600K

Edit

A little clarification… Network Manager is still showing me as connected, but I am unable to reach to gateway or anything beyond. At no point does NM suggest the connection is lost and calling ifconfig shows that I still have an IP address.

I tried connecting to a different gateway with a different cable and the same problem arises.

As requested:

lspci | grep -i eth
07:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)

dmesg | tail -f
[   14.024709] EXT4-fs (sda5): re-mounted. Opts: errors=remount-ro,commit=0
[   14.026443] EXT4-fs (sda7): re-mounted. Opts: commit=0
[   14.176101] hda-intel: IRQ timing workaround is activated for card #2. Suggest a bigger bdl_pos_adj.
[   23.917731] eth0: no IPv6 routers present
[  726.109697] r8169 0000:07:00.0: eth0: link up
[  733.169494] r8169 0000:07:00.0: eth0: link up
[  753.930119] r8169 0000:07:00.0: eth0: link up
[  880.787332] r8169 0000:07:00.0: eth0: link up
[ 1159.161283] r8169 0000:07:00.0: eth0: link up
[ 1406.623550] r8169 0000:07:00.0: eth0: link up

Edit

@roland-taylor: Network is always available under Windows. Pings do not timeout, applications do not complain of no network availability, large downloads are not interrupted or slowed.

Best Answer

Download the official realtek driver.

http://www.realtek.com/downloads/downloadsView.aspx?Langid=1&PNid=5&PFid=5&Level=5&Conn=4&DownTypeID=3&GetDown=false#2

Then remove the r8169 module from the linux kernel.

# rmmod r8169

<Quick install with proper kernel settings>
Unpack the tarball :
# tar vjxf r8168-8.aaa.bb.tar.bz2
Change to the directory:
# cd r8168-8.aaa.bb
If you are running the target kernel, then you should be able to do :
# ./autorun.sh (as root or with sudo)
You can check whether the driver is loaded by using following commands.
# lsmod | grep r8168
# ifconfig -a
If there is a device name, ethX, shown on the monitor, the linux
driver is loaded. Then, you can use the following command to activate
the ethX.
# ifconfig ethX up

Finally, blacklist the r8169 driver add the following to /etc/modprobe.d/blacklist.conf:

#blacklist r8169 driver
blacklist r8169

I found it at http://www.rvdavid.net/how-to-get-gigabit-speeds-from-rtl81118168b-pci-express-gigabit-ethernet-controller-on-ubuntu-linux/ and it works. Now it's all good with net speed.

Related Question