# [Solved] ethernet carrier loss, services stop

## lyallp

I have an issue whereby I have my laptop, at work, left on so I can remote connect from home.

However, if the LAN network goes down, ifplugd decides to shutdown eth0, which causes servers like ssh and samba, which depend on network, to also shutdown, due to their 'need net' dependency.

My /etc/conf.d/rc file contains RC_NET_STRICT_CHECKING="no", which means I need at least one network interface other than net.lo to be up in order to consider the net dependency satisfied. 

So, I am ok with ssh and samba being shutdown, the problem is, in following example, the network link came up but DHCP was unavailable for a period of time, longer than my timeout, resulting in my net.eth0 never being reactivated.

Worse, in my opinion, is if the network does come back up, dhcp does not acquire an IP and re-start the services of the runlevel, in this case, ssh and samba.

I could set RC_NET_STRICT_CHECKING="lo" to prevent ssh and samba from being shutdown but that isn't addressing my problem with the IP address being reacquired.

Edit: how to reproduce this situation.

Have a switch (8 port domestic one will do), have the laptop plugged into the switch.

The switch is plugged into the IP source (ADSL modem/workplace LAN)

Unplug the switch from the LAN

Unplug the laptop from the switch, carrier lost

Wait till eth0 is shutdown by ifplugd.

Plug the laptop back into the switch, but leave the switch unplugged from the LAN

Watch dhcp attempt to obtain a lease and fail.

Once dhcp fails, plug the switch back into the LAN.

Curiously, a Windows XP VM in VirtualBox will re-establish connectivity (bridged network) but the host does not.

Suggestions would be most welcome.

My ifplugd.conf is as follows :-

```
INTERFACES="eth0 wlan0"

ARGS="--ignore-fail --wait-on-fork --ignore-retval --delay-up=0 --delay-down=10"

ARGS_wlan0="--api-mode=wlan"

```

My /var/log/messages contents, for the network failure, is as follows :-

```
Feb 16 08:27:24 pearcely2 kernel: [61852.357393] e1000e: eth0 NIC Link is Down

Feb 16 08:27:24 pearcely2 dhcpcd[5409]: eth0: carrier lost

Feb 16 08:27:24 pearcely2 rc-scripts: status:  stopped

Feb 16 08:27:25 pearcely2 ifplugd(eth0)[3201]: Link beat lost.

Feb 16 08:27:31 pearcely2 ifplugd(eth0)[3201]: Executing '/etc/ifplugd/ifplugd.action eth0 down'.

Feb 16 08:27:31 pearcely2 ifplugd(eth0)[3201]: client:  [32;01m*[0m Unmounting network filesystems ...

Feb 16 08:27:32 pearcely2 ifplugd(eth0)[3201]: client: [A[72C  [34;01m[ [32;01mok[34;01m ][0m

Feb 16 08:27:32 pearcely2 ifplugd(eth0)[3201]: client:  [32;01m*[0m Stopping sshd ...

Feb 16 08:27:32 pearcely2 sshd[6745]: Received signal 15; terminating.

Feb 16 08:27:32 pearcely2 ifplugd(eth0)[3201]: client: [A[72C  [34;01m[ [32;01mok[34;01m ][0m

Feb 16 08:27:33 pearcely2 dhcpcd[5409]: received SIGTERM, stopping

Feb 16 08:27:33 pearcely2 dhcpcd[5409]: eth0: removing interface

Feb 16 08:27:33 pearcely2 ifplugd(eth0)[3201]: client: No resolv.conf for interface eth0

Feb 16 08:27:33 pearcely2 ifplugd(eth0)[3201]: Program executed successfully.

Feb 16 08:28:02 pearcely2 kernel: [61890.915264] e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX

Feb 16 08:28:02 pearcely2 kernel: [61890.915271] e1000e 0000:00:19.0: eth0: 10/100 speed: disabling TSO

Feb 16 08:28:03 pearcely2 ifplugd(eth0)[3201]: Link beat detected.

Feb 16 08:28:04 pearcely2 ifplugd(eth0)[3201]: Executing '/etc/ifplugd/ifplugd.action eth0 up'.

Feb 16 08:28:05 pearcely2 dhcpcd[23047]: version 5.2.8 starting

Feb 16 08:28:05 pearcely2 ifplugd(eth0)[3201]: client: dhcpcd[23047]: version 5.2.8 starting

Feb 16 08:28:05 pearcely2 dhcpcd[23047]: eth0: rebinding lease of 16.145.135.23

Feb 16 08:28:05 pearcely2 ifplugd(eth0)[3201]: client: dhcpcd[23047]: eth0: rebinding lease of 16.145.135.23

Feb 16 08:28:15 pearcely2 dhcpcd[23047]: eth0: broadcasting for a lease

Feb 16 08:28:15 pearcely2 ifplugd(eth0)[3201]: client: dhcpcd[23047]: eth0: broadcasting for a lease

Feb 16 08:28:24 pearcely2 kernel: [61912.433653] e1000e: eth0 NIC Link is Down

Feb 16 08:28:24 pearcely2 dhcpcd[23047]: eth0: carrier lost

Feb 16 08:28:24 pearcely2 ifplugd(eth0)[3201]: client: dhcpcd[23047]: eth0: carrier lost

Feb 16 08:28:35 pearcely2 dhcpcd[23047]: timed out

Feb 16 08:28:35 pearcely2 dhcpcd[23047]: allowing 8 seconds for IPv4LL timeout

Feb 16 08:28:35 pearcely2 ifplugd(eth0)[3201]: client: dhcpcd[23047]: timed out

Feb 16 08:28:35 pearcely2 ifplugd(eth0)[3201]: client: dhcpcd[23047]: allowing 8 seconds for IPv4LL timeout

Feb 16 08:28:36 pearcely2 kernel: [61924.560130] e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX

Feb 16 08:28:36 pearcely2 kernel: [61924.560136] e1000e 0000:00:19.0: eth0: 10/100 speed: disabling TSO

Feb 16 08:28:36 pearcely2 ifplugd(eth0)[3201]: client: dhcpcd[23047]: eth0: carrier acquired

Feb 16 08:28:36 pearcely2 dhcpcd[23047]: eth0: carrier acquired

Feb 16 08:28:36 pearcely2 dhcpcd[23047]: eth0: rebinding lease of 16.145.135.23

Feb 16 08:28:36 pearcely2 ifplugd(eth0)[3201]: client: dhcpcd[23047]: eth0: rebinding lease of 16.145.135.23

Feb 16 08:28:43 pearcely2 dhcpcd[23047]: timed out

Feb 16 08:28:43 pearcely2 ifplugd(eth0)[3201]: client: dhcpcd[23047]: timed out

Feb 16 08:28:43 pearcely2 ifplugd(eth0)[3201]: client: [A[72C  [34;01m[ [31;01m!![34;01m ][0m

Feb 16 08:28:43 pearcely2 ifplugd(eth0)[3201]: client: [A[72C  [34;01m[ [31;01m!![34;01m ][0m

Feb 16 08:28:43 pearcely2 ifplugd(eth0)[3201]: Program executed successfully.

```

----------

## gerdesj

The whole point of ifplugd is this should not happen!

Also, I think RC_NET_STRICT_CHECKING="no" should mean that only net.lo needs to be up for the network to be considered up.  The only two Gentoo machines I have to hand right now use the latest OpenRC (/etc/rc.conf instead)

I have never used /etc/ifplugd.conf ever in over five years of Gentoo'ing.  All plug related stuff belongs in /etc/conf.d/net You just have to emerge it and then if you need to turn it off for an interface then you use something like:

```

modules_wlan0="!plug"

```

Still, your log appears to show everything plug related working correctly but your dhcp client not getting a reply.

As a test can you give it a static IP address, then pull the cable and then plug it in - if that works OK then its the dhcp stuff that is failing and not the plug stuff.

Than you'll perhaps need a Wireshark trace on the eth0 interface to see where the problem crops up - ie which end (client or server) is broken.  You'll want to filter on ports 67 and 68 I think for DHCP. 

Cheers

Jon

----------

## lyallp

As I described in the original post, this is a laptop, so when I undock, ethernet disconnects, hence, I need to detect the loss and reconnection of ethrenet.

The simulation I gave, is to plug into a switch which is not connected to the LAN, thus, giving a wire level connection but no DHCP. I then connect the switch, about 30 seconds later, to the LAN, but by that time, the DHCP is no longer waiting.

If I simply unplug the network cable and put it back in, DHCP works just fine, it's when the network cable is plugged in and DHCP is not available within the first 30 seconds that the problem arises.

The problem arose when we had a LAN failure, at work, whereby network connectivity became available but not DHCP. I was unable to remotely access the laptop until I restarted the network.

As a workaround, whilst I continue investigating, I whipped up an hourly cron job which checks to see if the eth0 has an ip address, if it doesn't, it restarts eth0.

----------

## lyallp

Upon reflection, I may try removing the eth0 from the list of monitored networks in ifplugdev.conf

See if that makes a difference.

 :Smile: 

----------

## lyallp

Solved.

I threw out sys-apps/ifplugd.

I figured that since this was a laptop, I would need it, obviously not.

----------

