Why does my Ethernet port sometimes not work?
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
Related videos on Youtube
Oscar Godson
Fork me on Github: http://github.com/oscargodson Read my stuff: http://oscargodson.com
Updated on September 17, 2022Comments
-
Oscar Godson over 1 year
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.
-
maco over 13 yearsthe
dmesg | grep -i ethernet
was just another way of doing what I looked in 70-persistent-net.rules -- both lspci & dmesg commands were rather exploratory -
Oscar Godson over 13 yearsAny other ideas? :(
-
Oscar Godson over 13 yearsLooks like i got it up and working again if i do those commands above then sudo service network-manager stop, then sudo ifconfig, then sudo dhclient, THEN sudo service network-manager start. How can i make it do this on start?
-
-
Oscar Godson over 13 yearsI did the first thing you had me do, and I got the above (i edited my original post). The 2nd one i dont have a /udev/ directory in /usr/? Whys this?
-
maco over 13 yearsBecause I screwed up, sorry! I meant /etc/udev...
-
Oscar Godson over 13 yearsMaco, im getting the same result. After doing this (mine is also r8169) i ran sudo ifconfig eth0 up and it said the same as before "cannot allocate memory" then i did sudo dhclient eth0 and it gave me the output that i pasted above. Not sure if this helps but since this only happens when I go home, i suspect this only happens when i: use ethernet, unplug, use wifi, disconnect wifi, then plug in ethernet. Thanks so much! I really want this to work. It's a PITA to reboot every morning :)
-
maco over 13 yearswhat's the output of
free -m
? Are you actually out of memory? -
Oscar Godson over 13 yearsHmm, seems we might have found something: free -m output: pastebin.com/syX9jUx0 (think it's because it's 666? :P, but the first time I ran this I got only 32 free!) Here are all my running processes also: pastebin.com/DRVeMyht -- Any ideas?
-
Oscar Godson over 13 yearsSee my updated post above. I got that error to go away
-
Oscar Godson over 13 yearsI'm marking it as correct as it's as correct as it's going get. Thanks so much, and im reporting the bug now on LP.