When my system boots it should check for a given interface (e.g. eth0) whether a DHCP configuration is possible respectively if DHCP server exists within the network. If yes, DHCP should be used. If not, a pre-defined static IP address should be used.
- I know how to execute scripts at startup
- I know how to specify interfaces in /etc/network/interfaces
I tried playing around with dhclient, e.g.
dhclient -1 # Try once to get a lease. One failure, exit with code 2.
See http://www.computerhope.com/unix/dhclient.htm
However, dhclient returns always '0' even if there is not connection avilable at all.
What would be the correct approach?