Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8631823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:16:13+00:00 2026-06-12T09:16:13+00:00

I work on embedded device with linux on it. I want to use DHCP

  • 0

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):

  1. I set static IP with ifconfig, then I call udhcpc. If udhcpc will not obtain new IP, old one will stay.

  2. 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 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:16:14+00:00Added an answer on June 12, 2026 at 9:16 am

    dhclient should support fallback via lease declaration
    have a look at the dhclient.conf man page.

    Add something like this to your dhclient.conf

    timeout 10;
    lease {
    interface "eth0";
    fixed-address 10.0.0.10;
    option subnet-mask 255.255.255.0;
    renew 2 2022/1/1 00:00:01;
    rebind 2 2022/1/1 00:00:01;
    expire 2 2022/1/1 0:00:01;
    }
    

    or you can assign a second IP to the interface like /etc/network/interfaces

    auto lo
    iface lo inet loopback
    iface eth0 inet dhcp
    
    auto eth0:1
    iface eth0:1 inet static
    address 10.10.10.2
    netmask 255.255.255.0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work on a device that uses Embedded Linux. In the near future this
work on SQL Server 2000. want to Automated Email Notifications using SQL Server Job
I'm trying to use an API for a proprietary interface device on an embedded
I compiled and installed Qt for Embedded Linux and made sure to use -qt-gfx-vnc
So I have an embedded Linux device that is connected to a motor controller
I'm starting to work with Embedded Linux and I've got a LPC313x based board
My app is design to get messages from an embedded Bluetooth device. While I
I have a flash drive device (/dev/sda1) mounted to /mnt on an embedded linux
I'm trying to confirm a user a unplugged my embedded device from a network
I have developed a USB device that communicates with linux over a simple but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.