Ubuntu – Why does the Ethernet port sometimes not work

10.04hardwarelenovonetworkingthinkpad

I've noticed that my Ethernet port works fine once, but after it's disconnected and i connect to a wireless network and I go and try to plug the Ethernet port back in, it doesn't work until I reboot. Why is this?!

Also, the lights light up but it's like the Ubuntu doesn't see it. Is there a way to reboot the Ethernet port programmaticly through Terminal? I've also tried to delete and readd Auto Ethernet through the Network Preferences.

I have a Lenovo ThinkPad L512 with Ubuntu 10.04

==UPDATE==

I did the first step Maco said to do and here is what I got:

oscargodson@ubuntu:~$ sudo service network-manager stop
[sudo] password for oscargodson: 
network-manager stop/waiting
oscargodson@ubuntu:~$ sudo ifconfig eth0 up
SIOCSIFFLAGS: Cannot allocate memory
oscargodson@ubuntu:~$ sudo dhclient eth0
Internet Systems Consortium DHCP Client V3.1.3
Copyright 2004-2009 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

SIOCSIFFLAGS: Cannot allocate memory
SIOCSIFFLAGS: Cannot allocate memory
Listening on LPF/eth0/60:eb:69:02:50:f0
Sending on   LPF/eth0/60:eb:69:02:50:f0
Sending on   Socket/fallback
receive_packet failed on eth0: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
send_packet: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
send_packet: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 6
send_packet: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 11
send_packet: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 17
send_packet: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 17
send_packet: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
send_packet: Network is down
No DHCPOFFERS received.
No working leases in persistent database - sleeping.

I've tried everything Maco suggested and finally figured out my memory isn't low although I keep getting a SIOCIFFLAGS: Cannot allocate memory error. I have over 1GB of RAM free as we speak.

I found this page:
http://www.linuxquestions.org/questions/linux-newbie-8/weird-ethernet-problem-838220/

And did what the person there said which was:

lspci| grep -i ethernet
dmesg | grep -i ethernet

And it gave me some output and the last command gave me:

r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded

I then tried Maco's stuff again and i didn't get the error anymore, however, the Ethernet still doesn't connect although now it doesn't give me the memory allocation error.

Best Answer

Sounds like bug. Lets dig in.

First, stop Network Manager: sudo service network-manager stop

Then, plug in the cable and bring up the interface sudo ifconfig eth0 up and tell it to ask for a new dhcp lease sudo dhclient eth0 (I'm guessing it's eth0, if not use the right name)

Did it work? If so, file a bug on Network Manager: ubuntu-bug -p network-manager

If not, try reloading the network driver. This should simulate a reboot to the ethernet port. To find out your driver, look in /etc/udev/rules.d/70-persistent-net.rules You'll see some bits like:

# PCI device 0x10ec:0x8136 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:f1:4c:01:94:3e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Finding the one that matches your interface's name, look at what's in the parentheses where mine says r8169. That's your module's name.

sudo modprobe -r r8169 && sudo modprobe r8169

(replacing r8169 with your module's name) Try the dhclient step again. If that worked, I suspect it's a kernel bug. ubuntu-bug -p linux