Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I disable IPv4 stack from Linux ? I want to do that dynamically, ie. 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.

share|improve this question
    
Could you tell us what OS/Distribution you're running? –  HTDutchy Apr 7 '11 at 12:22
2  
You're doing it wrong. What problem do you want to solve by disabling IPv4? –  Benoit Apr 7 '11 at 13:33
    
What am I doing wrong ? I just want to be able to disable/enable IPv6 on a Linux machine. I'm using kernel 2.6.x, any distro, could be Ubuntu for instance. –  Aldebaran Apr 7 '11 at 13:52
1  
@Tarentula Your question was about IPv4 but now you speak about IPv6. Which one? Whatever the version, what is the purpose of disabling it? If you want to be sure to use one instead of the other you don't have to disable it. –  Benoit Apr 7 '11 at 14:39
    
How can I be sure that no service or protocol will use the IPv4 instead of IPv6 ? –  Aldebaran Apr 7 '11 at 19:05

3 Answers 3

up vote 10 down vote accepted

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).

share|improve this answer

Mostly you should recompile yours kernel without ipv4 modules. fedora

You cant disable it completely because system usese 127.0.0.1 lb interface. But you can disable some ipv4 functions with if-cfg command.

share|improve this answer
    
If so, you can use exec and switch kernels at runtime. –  Ency Apr 7 '11 at 12:40
    
@ency what? Can you point to documentation how you do that? That would be awesome! –  coredump Apr 7 '11 at 13:01
1  
@coredump:If MealstroM is right (I do not know if he is), but if so, you can have 2 kernels, so you shloud be able to switch them by kexec (sorry i noticed typo), it is kexec –  Ency Apr 7 '11 at 13:21
    
@ency never heard of kexec that's pretty nice stuff thanks for bringing that up! –  coredump Apr 7 '11 at 13:27
    
@coredump: you are right about ipv5 stack. many libs are based on ipv4. thats sad. –  MealstroM Apr 7 '11 at 13:29

If this is for developers, then "library interposition" could be used, with LD_PRELOAD some doctored library with stub functions that simply return errors (or that call the real ones depending on the day of the week or some other external criterion).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.