2

https://web.archive.org/web/20160528234959/https://wiki.freebsd.org/IPv6Only discusses a FreeBSD image that supported only IPv6, not IPv4. That page is no longer live, though (hence my archive link), and I can't find anything more recent about this. My question: is it possible today, on any modern UNIX or Linux system, to support only IPv6 and not IPv4, just like that old FreeBSD image did? It's okay if the way to do this requires a custom kernel or similar work.

Other places I've seen this asked (all dated after I originally asked this question):

3 Answers3

2

Just build FreeBSD.

It's possible today, because FreeBSD continues to provide the mechanism used.

It is a set of kernel configuration and makefile options to turn off or exclude IPv4. The basic one is nooptions INET, but observe what else /usr/src/sys/conf/makeLINT.mk does. Also observe what /usr/src/sys/conf/NOTES says about the knock-on effects of not having both IPv4 and IPv6 enabled.

Further reading

JdeBP
  • 68,745
0

Yes, of course. One way is simply not to configure any (public) IPv4 address or service on the host. More extreme would be to (if the OS supports that) remove IPv4 support, but that's more complicated, may not be possible, and if it is may break (usually older) services. Details will vary by OS as they are all very different in exactly how the network gets configured.

For example on macOS one might run

sudo ipconfig set en0 NONE
sudo ipconfig set en0 AUTOMATIC-V6

to disable IPv4 and enable IPv6 on en0. (lo0 might still have IPv4, but other systems need not know about that.)

This however may not be very useful as many things do not support or are not available on IPv6, and it's not like someone can call for a flag day like they did for the switch to TCP/IP a few years ago...

thrig
  • 34,938
0

It's certainly possible on Linux. Networking protocols in the kernel are configurable, you can remove all IPv4 stuff. However, most distros will expect IPv4 and try to use it, so you'll have to customize this part of your distro, too (and if only to get rid of the error messages).

Though of course the question is what do you gain from doing it that way. Yes, the kernel will be a bit smaller without IPv4 protocols. But it's a lot simpler to just use a stock kernel, and configure everything not to accept IPv4 addresses, or not to have IPv4 in the first place.

dirkt
  • 32,309
  • 3
    "Networking protocols in the kernel are configurable, you can remove all IPv4 stuff" I looked through make menuconfig, and I don't see any such options. I see an option to disable IPv6, and I see options to disable various pieces of functionality that apply to both IPv4 and IPv6. Can you specify exactly which CONFIG_* options you're talking about? – Joseph Sible-Reinstate Monica Sep 14 '18 at 18:28
  • You are right, there's only CONFIG_INET to disable both IPv4 and IPv6. I thought it was finer grained. So I guess you'd have to define CONFIG_INET4 and CONFIG_INET6, go through the kernel source and add #ifdef's - if you can remove both from the kernel, you certainly can remove one variant. The question is still why you would want to do that. – dirkt Sep 15 '18 at 08:39
  • 3
    For the moment, one reason is to have a proper platform for validating applications that must run in IPv6-only environments. It is unfortunate that Linux cannot do this; Windows has been able to completely remove the IPv4 stack since Vista! (And on Windows it is IPv6 that cannot be removed.) – Michael Hampton Apr 30 '19 at 19:05
  • @MichaelHampton Any reason why validation in IPv6 only environments can't be accomplished by not assigning IPv4 addresses to interfaces? And the Linux kernel is open source; if this feature is so important, sit down at the keyboard, spend half a day and sprinkle proper #ifdef's through the kernel code. It's not that "Linux can't do that", it's "nobody has found it important enough to implement it that way". If you feel different about that, go ahead and implement it. – dirkt May 01 '19 at 12:15
  • 1
    That's what people do now, only getting rid of 127.0.0.1 is a bit difficult. It would be much nicer if there were a sysctl, or better yet, a proper CONFIG_ define as you proposed. I'm sure someone will write it eventually and have the kernel developers reject it. – Michael Hampton May 01 '19 at 16:12
  • @MichaelHampton. Huh? ip addr del 127.0.0.1/8 dev lo works fine, I just tried it. And I don't see why the kernel developers should reject it if you can explain why its such a good thing. And if it's so important, but everyone else is stupid and doesn't see that it's so important, you can always fork. Has happened for other things. – dirkt May 01 '19 at 18:06
  • 2
    You can remove 127.0.0.1 from lo, but try having it not ever be added at all. – Michael Hampton May 01 '19 at 18:08
  • @MichaelHampton: Why should I want to not having it added at all, ever? For IPv6 only validation, I run a script to remove all IPv4 addresses. Then I validate. Possibly in a network namespace. Problem solved, no re-compiling of the kernel needed (if there were CONFIG_ options to get rid of IPv4). – dirkt May 02 '19 at 06:22
  • 1
    @dirkt Would be nice for IoT devices to remove all IPv4 functionality for size reasons. Only one IP stack would make it much leaner. – TJJ Jan 19 '21 at 02:45