Building a minimalist image - can't seem to remove dhcp server

I'm perplexed... I'm trying to remove DHCP (IPv4 and IPv6) from an image, but it still seems to be installed and running despite the fact that I've specifically set -odhcp6c -odhcpd in the image builder recipe...

Do I have a typo or some other thing I'm forgetting to remove?

make image PROFILE=tl-mr3020-v1 PACKAGES="-ppp -ppp-mod-pppoe -ip6tables -odhcp6c -odhcpd -kmod-ipv6 -kmod-ip6tables -iptables -firewall -opkg p910nd kmod-usb-printer avahi-daemon uhttpd uhttpd-mod-ubus libiwinfo-lua luci-base luci-mod-admin-full luci-theme-bootstrap luci-app-p910nd"

This is an 18.06.9 build for the TL-MR3020v1 (a 4/32 device). Yes, super outdated, insecure, and unsupported. The device is behind a firewall and running on a trusted LAN, only needs to run P910nd and ssh, and LuCI.

Disclaimer: no personal experience with the imagebuilder, but extrapolating from the buildroot behaviour.

You need to unravel the dependency tree, start from the leaf- to the root packages. If you want to remove odhcpd, you first need to get rid of everything that depends on it.

3 Likes

udhcp and odhcp6c are the DHCP clients.

The default servers are dnsmasq and odhcpd-ipv6only, which is installed instead of the full odhcpd by default since dnsmasq is expected to serve DHCPv4.

If you're slashing that much you may be able to install a new version. Wrapping services like dnsmasq under ujail is what really killed the prospect of running on 32 MB of RAM.

Note that Image Builder uses a pre-built kernel so in order to remove kmods that are "baked in" you need to build from source.

Avahi is quite large, to advertise a printer consider using umdns instead.

2 Likes

I've removed odhcp6c since I don't need the client for DHCPv6. I've left udhcp intact (not removed in my recipe) because I do want the DHCPv4 client.

The odhcpd is shown as 'safely removable' in this wiki page talks about what you can safely remove... it includes "remove dhcp server: -odhcpd". As it turns out, I've followed the entire recipe (except for adding zram). So if there are other things that are dependent on odhcpd, those are missing from the wiki recipe to remove.

But that does raise a question -- if you explicitly tell the image builder to remove/omit a package that is a dependency for other packages, does the IB figure that out and silently include the package as to not break others? Put another way, is it actually possible remove packages upon which other packages depend (with the obvious result of those packages breaking), or is this overridden by the IB itself?

I see odhcpd as a process running on my device. Of course, dnsmasq is, too. So I just ran an experiment and it turns out that odhcpd is indeed only serving DHCPv6 and dnsmasq is only serving DHCPv4.

Should I try removing odhcpd-ipv6only?

Good to know. How does one know if it is baked in vs a module that can be removed/omitted from an image? Would that mean reading through make files or similar?

What would happen if I tried to remove dnsmasq? I'm guessing that's baked in, so I guess that wouldn't be possible at the image builder level?? But would that break things horribly? I don't need any DNS or DHCP services on this thing.

Alternatively, I could always change the default configuration of the image such that the DHCP server is disabled on the lan. That might be the easier option, space not withstanding.

I'll give that a shot. Thanks for the suggestion.

You think so? I seem to recall being unable to find any profiles for this thing past 18.06 (obviously in the 'tiny' category)... but maybe I'm mistaken, so I'll look again. I can't imagine that 21.02 would be possible, but maybe 19.07??

Check the ath79 community builds by @Ashus, there's at least 19.07 and 21.02, recipes are included.

1 Like

I tried removing this, but it didn't change anything, so this must be baked in.

And I tried umdns... it is considerably smaller, but I couldn't get a service advertised. I tried two ways:

  1. json file in /etc/umdns per the documentation, but it didn't seem to work and it may have a bug as seen in this thread
  2. using the procd method shown here, but that also didn't appear to work.

I have gone back to avahi for now since it fits (barely, but hey). I've got a whopping 320.0K total space in my overlay, and 92.0K available :rofl:

1 Like

I'm not sure the image builder suffices to strip essential packages like a DHCP server. You will need to edit the list of required packages in the buildroot so you can manually strip it.

At this level the image builder is not the right tool anymore.

1 Like

Yeah, this appears to be the case.

The wiki page mentions compiling in passing, but doesn't make it clear what packages can be removed via IB vs which ones need to be turned off at compile time. I'm guessing that it would make sense to update the wiki page to be more explicit.