Linux – How to completely, dynamically disable IPv4 stack from Linux

ipv4ipv6linuxlinux-networkingnetworking

How can I disable IPv4 stack from Linux ? I want to do that dynamically, i.e. sometimes I want it enabled and sometimes I want only IPv6 stack. Is there any portable way to do that ? If you know how to do that in any distribution, it will also help me a lot.

Best Answer

Well after a little chat on the IRC the general opinion is that the linux kernel shares some code between ipv4 and ipv6, and that may make completely disabling ipv4 entirely impossible. You can try to compile the kernel without the ipv4 parts but ipv6 may not compile in this case (but nothing keeps you from trying!).

You can remove the ipv4 addresses from interfaces, AFAIK, but I don't think it's possible at this time to completely disable ipv4.

EDIT: After a quick check on make menuconfig on kernel 2.6.36 I could not find a way of disabling ipv4 without disabling the entire TCP/IP stack (and so, ipv6).