1

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
  • When I type /sys/class/net/eth0/carrier_changes the value 2 is always returned but I have no idea what it means and quick google search had no explanations. Sep 23, 2016 at 2:18
  • Thanks, mine has the value 4. I suspect it is showing trouble somewhere but likewise, I was not able to find any explanation.
    – S.R.
    Sep 23, 2016 at 8:05

2 Answers 2

4

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
  • Thanks Terrance, as I replied to WinEunuuch2Unix, I have a value of 4 in that file and network cable is attached at all times. Strange thing is, it doesn't happen every time because sometimes I do have a ready connection after boot.
    – S.R.
    Sep 23, 2016 at 8:14
  • @S.R. Correct. I just unplugged and plugged back in my cable with the system on, and now my carrier_changes shows 6. The files that are mentioned have nothing to do with your 2-3 minute internet connecting. I was explaining to you what I observed those files are for.
    – Terrance
    Sep 23, 2016 at 13:17
  • What you've observed looks like a side effect that can affect the value. Otherwise, it looks odd that it serves for counting how many times the network cable is attached/detached during a session because who does that? But it is certain that carrier can be used to determine if ethernet cable is connected.
    – S.R.
    Sep 23, 2016 at 20:45
  • @S.R. Yep, the carrier is used to determine if something is plugged in. As far as carrier_changes, apparently does keep track of cable removal and installs, or if my switch that it is plugged into turns off and on. This not only happens with my home system, but also my work systems, and servers that I deal with on a day to day. Something in the system might keep track of it for security or some type of reporting since pretty much everything in Linux is logged.
    – Terrance
    Sep 23, 2016 at 21:05
  • @S.R. These are only on the Ubuntu systems as far as I can see.
    – Terrance
    Sep 23, 2016 at 21:08
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .