# [CLOSE]ifplugd doesn't up interface when it fails to do so b

## cord

Hello, I have laptop (we call it client) with wired connection (enp2s0) and dhcp on it (dnsmasq on the other end, we call it server). If I start client before server (with cable plugged) it tries to obtain network settings and fails, so net is down (it uses udhcpc from busybox, it ussually reports that 'fails to start' when dnsmasq is down on the server). 

```
Oct 27 09:47:38 [ifplugd(enp2s0)] ifplugd 0.28 initializing.

Oct 27 09:47:38 [ifplugd(enp2s0)] Using interface enp2s0/6C:62:6D:30:D4:9E with driver <r8169> (version: 2.3LK-NAPI)

Oct 27 09:47:38 [ifplugd(enp2s0)] Using detection mode: SIOCETHTOOL

Oct 27 09:47:38 [ifplugd(enp2s0)] Initialization complete, link beat not detected.

Oct 27 09:47:51 [ifplugd(enp2s0)] Link beat detected.

Oct 27 09:47:52 [ifplugd(enp2s0)] Executing '/etc/ifplugd/ifplugd.action enp2s0 up'.

Oct 27 09:48:03 [ifplugd(enp2s0)] client:  *     start-stop-daemon: failed to start `/bin/busybox'

Oct 27 09:48:03 [ifplugd(enp2s0)] client:  * ERROR: net.enp2s0 failed to start

Oct 27 09:48:03 [ifplugd(enp2s0)] Program executed successfully.

Oct 27 09:48:18 [ifplugd(enp2s0)] Link beat lost.

Oct 27 09:48:21 [ifplugd(enp2s0)] Link beat detected.

```

But if I start server next it doesn't retrying to do so. I have to restart interface on client manually to get net up. So it 'thinks' that there's still no dhcp service on the server or it doesn't know is server up or down at all.

Is there way to make it retrying to up net over and over if the cable is plugged and the server is started after?Last edited by cord on Sun Oct 30, 2016 2:05 pm; edited 1 time in total

----------

## cord

Seems that ifplugd checks cable position only, and no way to define the dhcp-service is running remotely or not.

But the NetworkManager can do this.

----------

## UberLord

ifplugd (and other tools) have one chance to do something based on a cable event.

You have an error somewhere in /etc/ifplugd/ifplugd.action, or it's calling something that generated an error.

The error is likely of your own making - start-stop-daemon should not be calling busybox directly.

NetworkManager can do this because that logic is all self contained and compiled and you've likely not touched it.

dhcpcd will also work fine  :Smile: 

----------

## cord

 *UberLord wrote:*   

> ifplugd (and other tools) have one chance to do something based on a cable event.

 

Correct. It can't define is the 'dhcp-service' exists on the other end or not. While NetworkManager can.

 *UberLord wrote:*   

> You have an error somewhere in /etc/ifplugd/ifplugd.action, or it's calling something that generated an error.
> 
> The error is likely of your own making - start-stop-daemon should not be calling busybox directly.
> 
> 

 

No. Error is generated by udhcpc which is part of busybox. So, when the server is down (no dnsmasq working at the other end, so there's no distribution of network settings) udhcpc doesn't obtain anything ("fail to do it's job"), and busybox returns start-stop-daemon error.

----------

## UberLord

So you need to tell udhcpc to background (-b flag) if it cannot get a lease. But you don't want to use the -n flag as that will cause it to exit still.

----------

## cord

 *UberLord wrote:*   

> So you need to tell udhcpc to background (-b flag) if it cannot get a lease. But you don't want to use the -n flag as that will cause it to exit still.

 

Well, maybe it will remove the error, but I doubt that this will set udhcpc to reasking lease again, later.

----------

## cord

So, the problem was at the remote side - dnsmasq didn't provide lease.

The correct config for it is:

```

resolv-file=/etc/resolv.conf

dhcp-host=03:5f:25:b6:54:a2,192.168.0.2,12h

dhcp-range=wired,192.168.0.2,static

```

----------

