IPv6 is the most recent version of the Internet Protocol that provides a larger address space compared to IPv4. However, there may be scenarios where you need to disable IPv6 on an Ubuntu system, for instance, to troubleshoot network issues or if your network infrastructure does not support IPv6. This guide explains how to disable IPv6 on Ubuntu.
Methods to Disable IPv6 on Ubuntu
There are several methods to disable IPv6 on Ubuntu, ranging from temporary changes to permanent system configurations. You can choose the method that best suits your needs.
Method 1: Disable IPv6 Using sysctl (Temporary)
This method temporarily disables IPv6 until the system is rebooted. To disable IPv6 using sysctl
, follow these steps:
- Open a terminal.
- Run the following commands to disable IPv6 on all interfaces:
- sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
- Verify that IPv6 has been disabled by running:
- ip a | grep inet6
- If no IPv6 addresses are listed, the change has been successfully applied. However, the change will be lost after a reboot.
Method 2: Disable IPv6 Permanently Using sysctl
To permanently disable IPv6, you need to modify the system’s configuration files. This method ensures that IPv6 remains disabled even after a reboot:
- Edit the
sysctl.conf
file: - sudo nano /etc/sysctl.conf
- At the end of the file, add the following lines:
- net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
- Save the file and exit the editor.
- Apply the changes by running:
- sudo sysctl -p
- Verify IPv6 is disabled by checking for IPv6 addresses again:
- ip a | grep inet6
- If no IPv6 addresses appear, the changes were successful and IPv6 will remain disabled permanently.
Method 3: Disable IPv6 Using Network Manager
If you’re using a desktop environment like GNOME or KDE, you can disable IPv6 using the Network Manager tool:
- Click on the network icon in the system tray and open the Network Settings menu.
- Select the network interface for which you want to disable IPv6 (e.g., Wired or Wireless).
- Click the gear icon next to the selected interface and go to the IPv6 Settings tab.
- Change the Method dropdown to
Ignore
. - Click Apply to save the settings.
Method 4: Disable IPv6 Permanently via GRUB
For a permanent and system-wide solution, you can disable IPv6 via the GRUB configuration file. This method disables IPv6 at boot time, ensuring that IPv6 is not enabled even after a reboot.
- Edit the
GRUB
configuration file: - sudo nano /etc/default/grub
- Locate the line starting with
GRUB_CMDLINE_LINUX
and add the following entry: - GRUB_CMDLINE_LINUX=”ipv6.disable=1″
- Save the file and exit the editor.
- Update GRUB to apply the changes:
- sudo update-grub
- Reboot the system for the changes to take effect:
- sudo reboot
- After rebooting, verify that IPv6 has been disabled:
- ip a | grep inet6
- If no IPv6 addresses are listed, the change has been successfully applied, and IPv6 will remain disabled permanently even after system restarts.
Conclusion
Disabling IPv6 on Ubuntu can be useful for troubleshooting or when IPv6 is not supported in your network. You can either disable it temporarily using sysctl
, permanently by editing configuration files, or through the Network Manager tool if you’re on a desktop environment. Choose the method that fits your needs and ensure that your system behaves as expected.