1

I have a small Debian-based Linux device which set's its hostname by calling udhcpc:

udhcpc -i $interface -S -x hostname:mydevice

(Of course $interface is defined earlier in the script calls udhcpc.)

This works as intended, on my router I can see mydevice as active host name for this device.

My device - after obtaining the lease - mounts its new root file system from NFS and then chroots into it.

udhcpc will be sending renew requests to my router:

# cat /var/log/messages | grep dhcp
Jan  1 04:00:07 udhcpc: started, v1.28.1
Jan  1 04:00:07 udhcpc: sending discover
Jan  1 04:00:09 udhcpc: performing DHCP renew
Jan  1 04:00:09 udhcpc: sending discover
Jan  1 04:00:09 udhcpc: sending select for a.b.c.d
Jan  1 04:00:09 udhcpc: lease of a.b.c.d obtained, lease time 600
***NOW THE CHROOT HAPPENS***
Jan  1 04:05:09 udhcpc: sending renew to r.o.u.t
Jan  1 04:05:09 udhcpc: lease of a.b.c.d obtained, lease time 600
Jan  1 04:10:09 udhcpc: sending renew to r.o.u.t
Jan  1 04:10:09 udhcpc: lease of a.b.c.d obtained, lease time 600

I want to update the hostname after the chroot happens.

What have I tried:

  • killing udhcpc and restarting it with the new desired hostname: FAIL (NFS drops, system stalls)
  • checking udhcpc's manual: FAIL (haven't found any mention of updating hostname on a running instance)

Any idea is appreciated: all I want is to update the hostname on the active udhcpc.

Important: it's enough (accepted as answer) if I can update the hostname on a "sending renew to r.o.u.t" event.

0

From udhcpc --help:

-F NAME Ask server to update DNS mapping for NAME

For example: udhcpc -F $(hostname)

1
  • It didn't worked for me. Once udhcpc successfully set the hostname after bind, it's not able to update it. I had to modify udhcpc's source to reach that functionality. They might have been fixed it since then though. – Daniel Jan 6 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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