[Buildroot] DHCP default.script

David Laight David.Laight at ACULAB.COM
Tue Nov 30 09:10:19 UTC 2021


From: Nicolas Cavallari
> Sent: 29 November 2021 21:16
> 
> On 29/11/2021 18:19, David Laight wrote:
> > I was looking at the DHCP default.script (that ends up in /usr/share/udhcpd)
> > and found some quite nasty problems.
> > I've fixed them locally and ended up with the script below.
> > (Which is probably easier to read than a diff.)
> > I've ripped out ahavi - we don't need it (and i don't know what it does!).
> 
> It gives IPv4 link-local addresses (169.254.0.0/16) when DHCP fails.

Ah - that 'useful' feature.
I thought it was also responsible to the 'popup windows' every time
someone turns on/off a printer - that I don't seem to be able to disable.

> > 2) On a 'renew' it would delete all routes, not just the one added
> >     by dhcp.
> >     The 'proto dhcp' parameter can be used to identify routes added by
> >     dhcp so that they are the only ones deleted (this matches my desktop).
> 
> Busybox's iproute is very limited (e.g. it does not display the proto
> when listing routes) and 'dhcp' is not a builtin proto, so this needs a
> /etc/iproute2/rt_protos file to list 'dhcp'...

I've got the full 'ip' program installed to get namespace support.
The number could be used instead of the name - but that might
still need minor enhancements to the program.
If you've got dhcp installed the extra bit of code probably isn't
a problem - I suspect even the smallest embedded systems have more
memory and 'disk' space for slightly larger versions of many of
the 'busybox' programs - especially if they are running a recent
Linux kernel.

> > nl="$(printf '\nx')"
> > nl="${nl%x}"
> 
> or just
> 
> nl='
> '

Yes, but I've fallen foul of shell script files with dos line endings.
So I always use the longer form for safety.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


More information about the buildroot mailing list