2

The responsiveness of the Linux service udhcpc (native DHCP relative to /etc/init.d/S40network service which invokes ip up and udhcpc) differs before and after logging at the prompt.

When invoked via /etc/init.d/rcS (boot sequence), udhcpc does not assign an IP address:

udhcpc: no lease, failing

However, once logged in, with the root account, the S40network restart provides an IP address very quickly via udhcpc.

The /etc/inittab is normal and basic:

# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <[email protected]>
#
# Note: BusyBox init doesn't support runlevels.  The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id        == tty to run on, or empty for /dev/console
# runlevels == ignored
# action    == one of sysinit, respawn, askfirst, wait, and once
# process   == program to run

# Startup the system
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -o remount,rw /
::sysinit:/bin/mkdir -p /dev/pts
::sysinit:/bin/mkdir -p /dev/shm
::sysinit:/bin/mount -a
::sysinit:/bin/hostname -F /etc/hostname
# now run any rc scripts
::sysinit:/etc/init.d/rcS

# Put a getty on the serial port
ttyPS0::respawn:/sbin/getty -L  ttyPS0 0 vt100 # GENERIC_SERIAL

# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r

How can we explain this ?

perror
  • 3,171
  • 7
  • 33
  • 45
stefff
  • 21
  • 1
  • 4

1 Answers1

0

I had the same issue as you where it would fail during boot but would work just fine if manually invoked after that. In checking various logs I realized it looks like udhcpc was initializing while the interfaces were coming up, and as such the first few discovers weren't actually going out over the interface.

Ideally I'd make it so that udhcpc doesn't start until after the interface is stable, but since I didn't know how to accomplish that, I simply increased the number of tries udhcpc makes. Typically it gets an IP after 4-5 tries, but I increased the limit to 10 tries to cover any edge cases.

Add the the second line below to /etc/network/interfaces

iface eth0 inet dhcp
  udhcpc_opts -t 10 #sets max retries to 10
  #rest of config params