Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Turn IPv6 On or Off on Ubuntu

Check your IPv6 status and change it with one GRUB setting.

VPS and Cloud Servers2 min read6 steps6 screenshots

Steps

  1. Check the current IPv6 setting. If IPv6 is on, the command prints addresses:
ip -6 addr show
IPv6 addresses before the change
  1. Open the GRUB configuration file:
sudo nano /etc/default/grub
The GRUB file in nano
  1. Find the line that starts with GRUB_CMDLINE_LINUX_DEFAULT. To disable IPv6, add ipv6.disable=1 inside the quotes:
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
Disabling IPv6 in GRUB

If the line already has other options, keep them and add the new one with a space, for example "quiet splash ipv6.disable=1".

To enable IPv6, use ipv6.disable=0 or remove the option:

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=0"
  1. Save the file (Ctrl + O, Enter, Ctrl + X) and update GRUB:
sudo update-grub
Updating GRUB
  1. Reboot:
sudo reboot
Rebooting the server
  1. Check again:
ip -6 addr show
IPv6 status after the change

When IPv6 is off, the command shows no inet6 addresses.

Without a reboot

You can switch IPv6 off at once with sysctl. This change is lost at the next boot unless you save it in /etc/sysctl.conf:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

To turn it on again, set the values to 0.

Tip: Make a copy of /etc/default/grub before you edit it, so you can go back if the server does not boot.

Quick recap

  • Edit GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub.
  • Run sudo update-grub and reboot.
  • Verify with ip -6 addr show.