How to skip DHCP if no cable connected to ethernet in Debian
If you specify
allow-hotplug eth0
instead of
auto eth0
in /etc/network/interfaces
, then the connection will only be initiated by udev
when something triggers it, instead of at every boot.
That might be sufficient to handle your case, but not necessarily; the interfaces
manpage mentions that
(Interfaces marked "allow-hotplug" are brought up when udev detects them. This can either be during boot if the interface is already present, or at a later time, for example when plugging in a USB network card. Please note that this does not have anything to do with detecting a network cable being plugged in.)
You might need to use /etc/network/if-up.d/00check-network-cable
from the ifupdown-extra
package to skip the interface if no cable is connected.