0

I have a problem with hotplug ethernet in an embedded Linux (ver 3.6.0-rc5). If the network cable is connected during boot everything works fine. But if I connect the cable after boot I do not get an IP address.

My /etc/interfaces look like this:

# The loopback interface
auto lo
iface lo inet loopback

# Wired or wireless interfaces
allow-hotplug eth0
iface eth0 inet dhcp

My startup script includes this command:

ifup eth0

If the ethernet cable is connected at boot I get this after calling 'ifup eth0':

[   10.257995] davinci_mdio davinci_mdio.0: resetting idled controller
[   10.265319] net eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=davinci_mdio-0:00, id=7c0f1)
udhcpc (v1.19.4) started
Sending discover...
[   12.261260] libphy: davinci_mdio-0:00 - Link is Up - 100/Full
Sending discover...
Sending select for 192.168.86.100...
Lease of 192.168.86.100 obtained, lease time 86400
adding dns 192.168.86.1

If the ethernet cable is not connected at boot I get this after calling 'ifup eth0':

[   10.230285] davinci_mdio davinci_mdio.0: resetting idled controller
[   10.238037] net eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=davinci_mdio-0:00, id=7c0f1)
udhcpc (v1.19.4) started
Sending discover...
Sending discover...
Sending discover...
No lease, failing

If I then connect the ethernet cable I get this:

[  346.232391] libphy: davinci_mdio-0:00 - Link is Up - 100/Full

But I do not get an IP address.

So, it appears that Linux knows that the cable got connected, but it doesn't automatically ask for an IP address.
Note: If I do not call ifup during boot then nothing happens when I connect the ethetnet cable.

When the cable is connected I can get an IP address by doing this:

ifdown eth0
ifup eth0

Do I have to tell Linux to look for an address (e.g. ifdown/ifup)?
And if so: how do I do that?

  • After pluggin the cable in what happen if you do ifup eth0 again? – pippo1980 Apr 18 '21 at 20:53
  • Not sure this apply: https://unix.stackexchange.com/questions/192671/what-is-a-hotplug-event-from-the-interface – pippo1980 Apr 18 '21 at 21:32
  • @pippo1980 If I do ifdown and then ifup I do get an IP address. So if there is a script which gets called when the cable is connected then I guess I could just put ifdown/ifup in that script. – Henrik Bøgelund Apr 19 '21 at 08:05
  • used to play with openwrt a while ago ... but forgot everything ... think is related on how hotplug events are handled by your sytem but can't help sorry – pippo1980 Apr 19 '21 at 08:37
  • Look for udev but not sure all embedded systems have it (maybe something similar but smaller) : /etc/udev/rules.d/ – pippo1980 Apr 19 '21 at 20:10

0 Answers0