Re: How to renew lease when dhcpc function is provided with kernel
Roy Marples
Mon Jan 20 11:02:01 2020
Hi
On 20/01/2020 09:30, Xu, Yanfei wrote:
Hi,
My board is boot with nfs and "bootargs" has been filled with "ip=dhcp", the
kernel configured with CONFIG_IP_PNP_DHCP.
It's ok before the dhcp lease expires. After that, kernel don't renew the lease
and due to the nfsroot dhclient didn't run. DHCP server will reclaim the IP.
root@intel-x86-64:~# cat /sbin/dhclient-systemd-wrapper -n
1 #!/bin/sh
2
3 # In case the interface is used for nfs, skip it.
4 nfsroot=0
5 interfaces=""
6 exec 9<&0 < /proc/mounts
7 while read dev mtpt fstype rest; do
8 if test $mtpt = "/" ; then
9 case $fstype in
10 nfs | nfs4)
11 nfsroot=1
12 nfs_addr=`echo $rest | sed -e
's/^.*addr=\([0-9.]*\).*$/\1/'`
13 break
14 ;;
15 *)
16 ;;
17 esac
18 fi
19 done
20 exec 0<&9 9<&-
21
22 if [ $nfsroot -eq 0 ]; then
23 interfaces="$INTERFACES"
24 else
25 if [ -x /bin/ip -o -x /sbin/ip ] ; then
26 nfs_iface=`ip route get $nfs_addr | grep dev | sed -e 's/^.*dev
\([-a-z0-9.]*\).*$/\1/'`
27 fi
28 for i in $INTERFACES; do
29 if test "x$i" = "x$nfs_iface"; then
30 echony solution ab "dhclient skipping nfsroot interface $i"
31 else
32 interfaces="$interfaces $i"
33 fi
34 done
35 fi
36
37 if test "x$interfaces" != "x"; then
38 /sbin/dhclient -d -cf /etc/dhcp/dhclient.conf -q -lf
/var/lib/dhcp/dhclient.leases $interfaces *//dhclient didn't run due to our
boards is nfsroot*
39 fi
So, Is there any solution about this situation.
So, this list is for dhcpcd discussion, not dhclient discussion :)
dhcpcd can take over an initial kernel obtained lease very easily provided that
the kernel and dhcpcd provide the same client ID - or lack there-of and fall
back to the hardware address only.
You don't even need a script for a well formed DHCP server.
Roy
Archive administrator: postmaster@marples.name