To permanently disable IPv6 on Ubuntu 24 (or any recent version of Ubuntu), you can follow these steps. These instructions will disable IPv6 at the system level, so it won't be used by any applications or network interfaces.
1. Disable IPv6 via sysctl (recommended for persistent settings)
Ubuntu uses sysctl
to manage kernel parameters. You can modify these settings to disable IPv6.
Steps:
-
Open a terminal.
-
Edit the
/etc/sysctl.conf
file or create a custom configuration file under/etc/sysctl.d/
:sudo vim /etc/sysctl.d/99-disable-ipv6.conf
-
Add the following lines to disable IPv6:
# Disable IPv6 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 (press
Ctrl+X
, thenY
to confirm, andEnter
). -
Apply the changes immediately:
sudo sysctl --system
2. Disable IPv6 via GRUB (alternative method)
This method modifies the boot loader (GRUB) to disable IPv6 during the system startup.
Steps:
-
Edit the GRUB configuration file:
sudo vim /etc/default/grub
-
Find the line starting with
GRUB_CMDLINE_LINUX
and appendipv6.disable=1
to the existing options. For example:GRUB_CMDLINE_LINUX="... ipv6.disable=1"
-
Save the file and exit (press
Ctrl+X
, thenY
to confirm, andEnter
). -
Update GRUB to apply the changes:
sudo update-grub
-
Reboot your system:
sudo reboot
3. Verify IPv6 is Disabled
After rebooting, you can check if IPv6 is disabled by running the following command:
ip a | grep inet6
You should see no output, meaning there are no IPv6 addresses assigned to your interfaces.
Alternatively, you can use:
sysctl net.ipv6.conf.all.disable_ipv6
sysctl net.ipv6.conf.default.disable_ipv6
Both should return 1
indicating that IPv6 is disabled.