Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using an embedded linux distro with busybox utilities. During system boot I am configuring my interface via DHCP in startup scripts.

/etc/rcS.d/S40networking |---------> ifup -a

Now the problem is my interface link is brought up after some time (i.e 3 - 4 seconds), but after bringing up the interface (before Link is actually up), the ifup calls udhcp to get IP address from DHCP which is eventually failed as interface is not brought up at this time.

Just after S40networking I am running one of my own script / application which utilizes network stuff, again at this time interface is still not brought up and I don't have an IP, so my application also fails.

My question is how can I pause S40networking to not continue until my Link is actually up, or why my interface is taking long to bring up the actual link. sleep 5 after ifup -a in S40networking does work, but I want to avoid it. I am sending ip::::::eth0:off in my kernel command line.

Thoughts ?

Regards, Farrukh Arshad.

share|improve this question
Any thoughts on this – Farrukh Arshad Mar 18 '13 at 7:40
up vote 1 down vote accepted

Ok. I have found a solution for myself. Not sure if this is the most optimized solution or not, but here are my reasons.

1) I don't want to bring-up ethernet module at kernel startup, to avoid ip=dhcp or ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:eth0:off, since I am not sure what will be the end-user setup.

2) I have written my own network configuration script which bring-up network interface as shown below.

linkups="Link is Up"

function error_out
    exit -1
function search_ifc_dev()
    for iface in `awk '{print $1}' /proc/net/dev | cut -f1 -d":"`; do
        if [[ ${iface} == eth* ]]; then
    if [[ ${interface} == "" ]]; then
        echo "Unable to find network interface. Can not continue"

function wait_for_link_up()
    startsec=`date +%s` 
    endsec=`expr ${startsec} + ${link_up_waittime}`
    while [[ ${startsec} -lt ${endsec} ]]; do
        found=`dmesg | grep "${linkups}"`   
        if [[ ! -z ${found} ]]; then
        # Increment current time
        startsec=`date +%s`

    # We will not continue if interface can not be brought up..."
    if [[ -z ${found} ]]; then
        echo "Unable to bring up interface. Can not continue"

function dynamic_ip_assign()
    ifconfig ${interface}
    udhcpc -D -s /usr/share/udhcpc/default.script

Lets look into this script. search_ifc_dev will search for the device name assigned to the ehternet interface by the kernel. (You must have only one interface for this to work).

dynamic_ip_assign will assign ip address dynamically. I am using ifconfig instead of ifup -a because ifup -a automatically calls (see man interfaces) udhcpc or dhcpclient utilities (if you have configured your iface as dhcp in /etc/network/interface) without waiting for the interface to bring-up actually. This causes the problem when your DHCP server is responding (most of the cases) slow, since your network script will exit before the interface is actually brought up and your own application launch script will start and your interface is still not up. You can see above I am waiting for the link to UP before I continue towards exit from my script, so whenever I am launching my own application in the startup I am sure that interface is actually brought up, otherwise I can do something nice in error_out function.

Note that if you are using ip=dhcp in the kernel command line, your ethernet driver will not continue untill your interface is actually up, so whenever you application launch script will be invoked you are sure that interface is already UP, but as I have mentioned I don't want to provide ip parameter in the kernel command line.

Anyone please provide feedback if you have a compact solution to this problem. Also note that this is a custom embedded distro so I am short of networking utilities except busybox. Using some other utility (as being used in desktop distros) might give me a compact solution.

Regards, Farrukh Arshad.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.