18

I know there is a parameter named ip which lets you configure IPv4 addresses on the Linux kernel through the boot loader. That looks like the following:

ip=192.0.2.1::192.0.2.62:255.255.255.192::eth0:none

I'm looking for an equal parameter for IPv6 configuration. I couldn't find anything about this in the kernel documentations.

Update: Because of a lot of you asked why I would need this: The idea to use a kernel configuration came up related to this problem. I suspect the regular boot-up interface configuration is not done, because the interfaces are already up. The reason for this could be that I'm using a pre-boot environment with a Dropbear SSH server to allow me to unlock my encrypted root partition. The IP addresses for this environment are configured through GRUB with the ip= parameter. There is no DHCP or Router Advertisement available on that Ethernet segment and as this is the uplink segment provided by a large hosting company, there is no way to change that fact.

aef
  • 1,705
  • 4
  • 24
  • 41
  • In fact, there isn't one. You can enable IPv6 autoconfiguration, but that is probably not what you are looking for. Is there a specific result you're trying to achieve (i.e. what is the reason you want to avoid IPv6 configuration in the machine's initialization process?) The `ip=` parameter was initially meant to configure the IP stack before the kernel tries to mount a NFS root filesystem, but I feel that you should rely on something else to achieve the same result with IPv6 (most probably, SLAAC). – pino42 Nov 04 '12 at 16:08
  • I know about SLAAC. But I need to set it up manually. – aef Nov 04 '12 at 17:57
  • 3
    My feeling is that since the introduction of the "early userspace" feature (initramfs either embedded in the kernel or as a separate file like traditional initrd), you are encouraged to do such things as configuring IP addresses there instead of with special one-off command line parameters. That's probably why there is a historical command line parameter for IPv4 but none was added for IPv6. – Celada Nov 04 '12 at 19:19
  • At what time in the boot process do you need it to be set? – pino42 Nov 05 '12 at 09:17
  • It's extremely unlikely that you need this. What _exactly_ are you trying to accomplish? – Michael Hampton Nov 15 '12 at 16:26
  • I've updated my question to give some detail on the reasons why I went looking for this option. – aef Nov 16 '12 at 16:20
  • @aef What did you end up doing? I have exactly the same circumstances that you have. – Neil Mar 17 '16 at 00:25
  • @MichaelHampton: I had the same question like aef in mind, but for a different purpose: Unlocking a LUKS-encrypted root partition with a dropbear SSH daemon running from initramfs and accessing that one by IPv6. IMHO that's a very valid and in future rather common reason to want this. Actually Debian's dropbear-initramfs package even reminds me: "Don't forget to check your "ip=" kernel bootparameter to match your desired initramfs ip configuration." The desired IP configuration is clearly an IPv6 one. – Axel Beckert Jul 15 '16 at 11:37

4 Answers4

8

Sorry, but if you want this, you'll have to build it yourself, or more likely, reuse someone else's implementation.

The ip= command line option you've been using is actually part of the kernel's boot code for mounting an NFS root filesystem. It has never been extended for IPv6, and there is no kernel boot parameter for configuring IPv6 at boot time.

That said, some Linux distributions such as Red Hat have implemented their own ipv6= boot parameter for their installation media. You may be able to reuse this code in your custom initramfs.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
4

According to Fedora, the ip= parameter can be used with IPv4 or IPv6 addresses. IPv6 addresses must be enclosed in square brackets. If you need both, you can use multiple ip= options on the kernel line as in:

... ip=[2001:db8::dead:beef]::[2001:db8::cafe:babe]:64::eth0:none ip=192.0.2.5::192.0.2.1:255.255.255.0::eth0:none ...

Owen
  • 41
  • 1
  • 1
    This answer is contradicting the accepted answer. This may be due to the accepted answer being outdated. To remove any doubt about which answer is correct, it would be a good idea to include a link to the source of this information. – kasperd Jun 25 '15 at 10:07
  • 1
    This is probably an evolution of the thing RedHat implemented, which was mentioned in Michael Hampton's answer. I tested it in Debian Jessie and it didn't work. I am still looking for a generic Linux way to do it. – aef Jul 09 '15 at 13:30
2

All your boot parameters are available via /proc/cmdline after boot. So, you can just set up all needed options via custom mkinitcpio hook, which would parse cmdline in search for specific param. You can use ipv6= like ip= one.

Alex Laskin
  • 181
  • 2
  • Yeah. I could build it myself, but that was not what I'm looking for. Still thanks for the idea. – aef Nov 16 '12 at 16:11
0

Here is how it looks like in Hetzner's Rescue mode (Debian 11):

root@rescue ~ # cat /proc/cmdline
initrd=rescue/current-amd64/initramfs.cpio.zst nfsdir=[2a01:4ff:ff00::b007:1]:/nfs RFILE=rescue-amd64-bullseye-v002.ext2 HASH=$5$XuSCY.REDACTED net.ifnames=0 vga=0x317 lang=de quiet IP6=REDA:CTED:4a:28c5:: IP6MASK=64 IP6GW=fe80::1 config_url=https://admin-robot.your-server.de/admin/api/boot/order/redacted BOOT_IMAGE=rescue/current-amd64/vmlinuz BOOTIF=aa-bb-cc-ee-7b-e6
Andrey Zentavr
  • 161
  • 1
  • 1
  • 5