How to Disable IPv6 on Your Raspberry Pi

Ben
Ben
@benjislab

IPv6 might be the future of internet protocols, but there are times when disabling it is necessary, especially if you are working with older equipment that doesn’t support IPv6, or if you are troubleshooting network issues. Disabling IPv6 on your Raspberry Pi can help improve compatibility and performance in such cases. Here’s how to do it:

Equipment Needed

  • Raspberry Pi with Raspberry Pi OS installed
  • Access to the terminal or command line

Open the Terminal

You can access the terminal directly if you are using a monitor and keyboard connected to your Raspberry Pi, or you can connect to your Raspberry Pi remotely via SSH.

Disable IPv6 using sysctl

The sysctl command allows you to modify kernel parameters at runtime. To disable IPv6 using this method:

  1. Open the sysctl configuration file:
sudo nano /etc/sysctl.conf
  1. Add the following lines at the end of the file to disable IPv6:
net.ipv6.conf.all.disable_ipv6 =  1  net.ipv6.conf.default.disable_ipv6 =  1net.ipv6.conf.lo.disable_ipv6 =  1
  1. Save and close the file. Press CTRL+X to exit, then Y to save changes, and Enter to confirm.

  2. Apply the changes:

sudo sysctl -p

This command will reload the sysctl settings from the configuration file you just edited.

Update the GRUB bootloader

For a more permanent solution that prevents IPv6 from being enabled on boot, you can update the GRUB bootloader configuration:

  1. Edit the GRUB configuration file:
sudo nano /etc/default/grub
  1. Find the line starting with GRUB_CMDLINE_LINUX_DEFAULT, and add ipv6.disable=1 to the existing parameters. Make sure each parameter is separated by a space. For example:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"
  1. Save and close the file, then update GRUB:
sudo  update-grub

Reboot Your Raspberry Pi

For all changes to take effect, reboot your Raspberry Pi:

sudo reboot

Conclusion

Disabling IPv6 on your Raspberry Pi is a straightforward process that can be done by editing system configurations and settings. Whether you need to disable IPv6 for compatibility reasons or to streamline your network settings, following these steps will help you achieve your goal without impacting the overall functionality of your Raspberry Pi. Remember, if you ever need to re-enable IPv6, you can reverse these changes by editing the same configuration files.