# ifplugd and dhcp

## ChrisG

Hi,

I cant seem to get dhcp working with ifplugd.  However, when I run it manually it does work:

```

rob sbin # dhcpcd -d eth0

dhcpcd: MAC address = 00:00:e2:96:1c:13

dhcpcd: your IP address = 192.168.0.177

rob sbin # ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:00:E2:96:1C:13

          inet addr:192.168.0.177  Bcast:192.168.0.255  Mask:255.255.255.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:852 errors:0 dropped:0 overruns:0 frame:0

          TX packets:784 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:521789 (509.5 Kb)  TX bytes:126108 (123.1 Kb)

          Interrupt:11 Base address:0x2000

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:4 errors:0 dropped:0 overruns:0 frame:0

          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:200 (200.0 b)  TX bytes:200 (200.0 b)

```

When I run dhcpcd manually, the following appears in the messages:

```

Jun 26 10:32:23 rob dhcpcd[7702]: broadcasting DHCP_DISCOVER

Jun 26 10:32:25 rob eth0: Media Link On 100mbps full-duplex

Jun 26 10:32:29 rob dhcpcd[7702]: broadcastAddr option is missing in DHCP server response. Assuming 192.168.0.255

Jun 26 10:32:29 rob dhcpcd[7702]: dhcpIPaddrLeaseTime=86400 in DHCP server response.

Jun 26 10:32:29 rob dhcpcd[7702]: dhcpT1value is missing in DHCP server response. Assuming 43200 sec

Jun 26 10:32:29 rob dhcpcd[7702]: dhcpT2value is missing in DHCP server response. Assuming 75600 sec

Jun 26 10:32:29 rob dhcpcd[7702]: DHCP_OFFER received from  (192.168.0.250)

Jun 26 10:32:29 rob dhcpcd[7702]: broadcasting DHCP_REQUEST for 192.168.0.177

Jun 26 10:32:29 rob dhcpcd[7702]: dhcpIPaddrLeaseTime=86400 in DHCP server response.

Jun 26 10:32:29 rob dhcpcd[7702]: dhcpT1value is missing in DHCP server response. Assuming 43200 sec

Jun 26 10:32:29 rob dhcpcd[7702]: dhcpT2value is missing in DHCP server response. Assuming 75600 sec

Jun 26 10:32:29 rob dhcpcd[7702]: DHCP_ACK received from  (192.168.0.250)

Jun 26 10:32:29 rob dhcpcd[7702]: No resolv.conf.sv to restore

```

If I configure ifplugd to run instead, and run "ifplugd eth0" to test it (having first used dhcpcd -k to disable the interface of course) the following output appears in the messages file:

```

Jun 26 10:34:23 rob ifplugd[7733]: Warning: Could not get interface address.

Jun 26 10:34:23 rob ifplugd[7733]: Using interface eth0/00:00:E2:96:1C:13 with driver sis900 v1.08.07 11/02/2003

Jun 26 10:34:23 rob ifplugd[7733]: ETHTOOL_GLINK failed: Operation not supported

Jun 26 10:34:23 rob ifplugd[7733]: ifplugd 0.13 successfully initialized, link beatnot detected.

Jun 26 10:34:25 rob eth0: Media Link On 100mbps full-duplex

Jun 26 10:34:25 rob ifplugd[7733]: Link beat detected.

Jun 26 10:34:25 rob ifplugd[7733]: Executing '/usr/sbin/ifplugd.action eth0 up'.

Jun 26 10:34:25 rob dhcpcd[7736]: broadcasting DHCP_DISCOVER

Jun 26 10:34:26 rob dhcpcd[7736]: broadcastAddr option is missing in DHCP server response. Assuming 192.168.0.255

Jun 26 10:34:26 rob dhcpcd[7736]: dhcpIPaddrLeaseTime=86400 in DHCP server response.

Jun 26 10:34:26 rob dhcpcd[7736]: dhcpT1value is missing in DHCP server response. Assuming 43200 sec

Jun 26 10:34:26 rob dhcpcd[7736]: dhcpT2value is missing in DHCP server response. Assuming 75600 sec

Jun 26 10:34:26 rob dhcpcd[7736]: DHCP_OFFER received from  (192.168.0.250)

Jun 26 10:34:26 rob dhcpcd[7736]: broadcasting DHCP_REQUEST for 192.168.0.177

Jun 26 10:34:26 rob dhcpcd[7736]: dhcpIPaddrLeaseTime=86400 in DHCP server response.

Jun 26 10:34:26 rob dhcpcd[7736]: dhcpT1value is missing in DHCP server response. Assuming 43200 sec

Jun 26 10:34:26 rob dhcpcd[7736]: dhcpT2value is missing in DHCP server response. Assuming 75600 sec

Jun 26 10:34:26 rob dhcpcd[7736]: DHCP_ACK received from  (192.168.0.250)

Jun 26 10:34:26 rob dhcpcd[7736]: No resolv.conf.sv to restore

Jun 26 10:34:26 rob ifplugd[7733]: client: dhcpcd: MAC address = 00:00:e2:96:1c:13

Jun 26 10:34:26 rob ifplugd[7733]: client: dhcpcd: your IP address = 192.168.0.177

Jun 26 10:34:26 rob ifplugd[7733]: client: dhcpcd: MAC address = 00:00:e2:96:1c:13

Jun 26 10:34:26 rob ifplugd[7733]: client: dhcpcd: your IP address = 192.168.0.177

Jun 26 10:34:27 rob ifplugd[7733]: client:  dhcpcd is already running on eth0

Jun 26 10:34:27 rob rc-scripts: dhcpcd is already running on eth0

Jun 26 10:34:27 rob ifplugd[7733]: Program executed successfully.

```

As you can see, dhcpcd is run, and the IP address is obtained, but when I run ifconfig -a I get the following output:

```

eth0      Link encap:Ethernet  HWaddr 00:00:E2:96:1C:13

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1180 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1038 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:870266 (849.8 Kb)  TX bytes:164063 (160.2 Kb)

          Interrupt:11 Base address:0x2000

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:4 errors:0 dropped:0 overruns:0 frame:0

          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:200 (200.0 b)  TX bytes:200 (200.0 b)

```

No IP address...

This is really bugging me now.  I can bring up the interface manually, but not automatically.  I have been reading posts about similar problems on this forum, but cant seem to get it all working still.  Can anyone help?

/Chris.

----------

## realsight

i dont understand why u don not add dhcpcd to your init.d

----------

## bonbons

 *ChrisG wrote:*   

> If I configure ifplugd to run instead, and run "ifplugd eth0" to test it (having first used dhcpcd -k to disable the interface of course) the following output appears in the messages file:
> 
> As you can see, dhcpcd is run, and the IP address is obtained, but when I run ifconfig -a I get the following output:

 Take a look at /etc/conf.d/ifplugd, there is mention of a bug related to -a (AUTO) option.

```
If you set AUTO to yes, you have to read http://bugs.gentoo.org/show_bug.cgi?id=28362
```

Might be your card is part of those triggering the issue.

----------

## ChrisG

Hi,

Thanks for the replies:

bonbons: I dont use the -a or "auto" option - I specify eth0.  In any case, I have the latest version of baselayout available on portage, which should have fixed that bug.

realsight: I would rather use ifplugd if possible, since it will bring the interface up and down automatically, and it helps prevent the computer waiting on boot until the timeout finishes if there is no network available.

----------

## ChrisG

One thing I forgot to say is that this was all working before my last emerge (which was pretty big - I have not had the opportunity to do this for a couple of months).

Any ideas why ifplugd executes dhcpcd, and the ip address is obtained but not set?

----------

## ChrisG

*bump*

Surely someone has dchp working with ifplugd on a current install of gentoo?  Any chance I could have a copy of the relevent configuration files?  Maybe I am doing something blindingly stupid?

/Chris

----------

## UberLord

Try using another dhcp client such as udhcpc or dhclient.

The problem I think is that dhcpcd is bringing down the interface with stops ifplugd from detecting if the cable is in or out.

Or you can install dhcpcd-1.3.22_p4-r10 and add -o to your dhcpcd options

```
dhcpcd_eth0="-o"
```

----------

