title: Set static ip if not obtained from DHCP (script)
body: <p>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.</p>
  
  <p>I'm thinking about 2 solutions (Unfortunately I can test them in few days):</p>
  
  <ol>
  <li><p>I set static IP with ifconfig, then I call udhcpc. If udhcpc will not obtain new IP, old one will stay.</p></li>
  <li><p>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.</p></li>
  </ol>
  
  <p>BR
  Bartek</p>
  
  <p>I use udhcpc - something like: </p>
  
  <pre><code>udhcpc -n -f -i eth0 
  if ifconfig | grep -A1 eth0 | grep inet 
      then 
  </code></pre>