The meaning of /sys/class/net/eth0/carrier_changes values

Can anybody tell me what do the numbers stored in that file mean? As of late, it takes 2-3 minutes for internet connection to be established after the boot has been completed and I want to find out why.

2

2 Answers

From my observations, there are two files that have meaning there in /sys/class/net/eth0/ together. The first one being carrier and the second being carrier_changes. These files have nothing to do with your internet taking 2-3 minutes to connect.

From my testing it looks as though when you unplug a cable from your eth0 port, the carrier file shows a 0 and the carrier_changes increases by one. Plugging the cable back in changed carrier to 1 stating it has connection, and carrier_changes increase by a count of one again. Example below:

Starting with cable connected:

terrance@terrance-ubuntu:/sys/class/net/eth0$ cat carrier_changes
2
terrance@terrance-ubuntu:/sys/class/net/eth0$ cat carrier
1

Removed cable:

terrance@terrance-ubuntu:/sys/class/net/eth0$ cat carrier
0
terrance@terrance-ubuntu:/sys/class/net/eth0$ cat carrier_changes
3

Reconnected cable:

terrance@terrance-ubuntu:/sys/class/net/eth0$ cat carrier
1
terrance@terrance-ubuntu:/sys/class/net/eth0$ cat carrier_changes
4

So, as it looks, carrier_changes keeps track of how many times the cable is removed and connected with the system up or a possible network change has been performed.


Other possible reasons or solutions to why you might have slow connecting times:

Cable / connectors on cable might be bad. Try another cable to router.

Another thing you can possibly look at is how long it takes for your eth0 to actually get an IP address. Maybe perform a watch command on ifconfig eg: watch -n 5 'ifconfig eth0'

Maybe look at how long your router has DHCP leases set for. Maybe you're low on IP addresses in your scope on your router and it is waiting until another is free.

Maybe try a power reset on your system by removing all power from the system then pressing the power button a few times to drain all remaining power from the system. Then plug it back in and power it on.


Hope this helps!

6

This can also happen if you connect two gigabit ethernet interfaces with a Cat5 ethernet cable (gigabit connection needs Cat6 cables).

You can test disabling the auto-negotiation and fixing the connection to fast ethernet:

# ethtool -s YOUR_INTERFACE_NAME speed 100 duplex full autoneg off

In order to make this permanent over reboot, the way changes depending on the Linux distribution you're using, have a look here, here and here.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like