Imre Péntek

The kernel ip= parameter: what each field actually does

I was writing an automated Proxmox installer with full-disk encryption and remote SSH unlock, which means a Dropbear SSH server inside the initramfs, which means the initramfs needs a working network stack, which means filling in this kernel parameter correctly. The format took some untangling. Here’s what I learned.

According to official documentation, my whole article in a single line is as follows:

ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>:<ntp0-ip>

I’ve investigated that from the viewpoint of Dropbear LUKS unlocking. This is what I have:

ip=<client-ip>::<gw-ip>:<netmask>::<device>:off

One caveat though: the Dropbear initramfs config file (/etc/initramfs-tools/conf.d/dropbear-ip.conf) uses uppercase IP=, while the kernel uses lowercase ip=.

On my system this parameter is in the aforementioned file, however providing an alternative ip= from kernel commandline using grub overrides the contents of that file. Good for testing.

The fields I’ve populated:

The fields I haven’t populated:

24 vs 255.255.255.0

CIDR stands for Classless Inter-Domain Routing, 127.0.0.1/8 is what we call the CIDR style IP notation. However the fourth parameter in ip is a dotted netmask. When the ip parsing was written in the kernel, the dotted representation was still the norm, and kernel wants to maintain backwards compatibility.

Conclusion

In this article we walked through the kernel ip parameter field by field. The format is a small fossil, but a useful one to know if you ever want to talk to a kernel before user-space exists. Like in this example, booting up Dropbear from initramfs. In this case we need only half of the fields. Now we know which ones, and why.