I work on embedded device with linux on it. I want to use DHCP client first, but if there will be no answer from DHCP Server I want to set static-default IP. I suppose it shouldn't be complicated, but I haven't found strict answer.
I'm thinking about 2 solutions (Unfortunately I can test them in few days):
I set static IP with ifconfig, then I call udhcpc. If udhcpc will not obtain new IP, old one will stay.
I can also first call udhcpc, wait a while and check if IP is obtained. But this is not nice for me. I wouldn't like to add any wait routines into startup.
BR Bartek
I use udhcpc - something like:
udhcpc -n -f -i eth0
if ifconfig | grep -A1 eth0 | grep inet
then