How to disable ipv6 in Ubuntu system? Two methods of operation will be introduced in this article.
IPv6 Introduction
IPv6 is designed to improve security and performance while ensuring that we do not run out of IP addresses. It assigns a unique address globally to each device and stores it in 128-bit form, while IPv4 has only 32-bits. Although IPv6 aims to replace IPv4, it still has a long way to go. For now, less than 30% of websites or users on the Internet can connect using IPv6, and IPv6 may also cause problems for some applications.
Method 1: Use Sysctl to disable IPv6 protocol in Ubuntu
Execute the following command in “terminal”-check whether IPv6 is enabled:
$ ip a
If the IPv6 protocol is enabled (your network card name may be different), you should see it like below screen:
To temporarily disable IPv6, you only need to execute the following 3 commands in the “terminal”:
$ 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
After the above command is executed, use ‘ip a’ to check whether IPv6 is successfully disabled:
Note: The above method only temporarily disables the IPv6 protocol in the Ubuntu system, and the system will automatically enable IPv6 again after restarting.
If you want to permanently disable IPv6 in the Ubuntu system, we can modify the /etc/sysctl.conf file through the editor of this article:
Step 1 – Use a file editor such as VIM or Nano to open the /etc/sysctl.conf configuration file
Step 2 – Add the following 3 lines to the /etc/sysctl.conf configuration file:
$ net.ipv6.conf.all.disable_ipv6=1
$ net.ipv6.conf.default.disable_ipv6=1
$ net.ipv6.conf.lo.disable_ipv6=1
Step 3 – After the configuration file is modified, to make the settings effective, you need to execute the following commands in the “terminal”:
$ sudo sysctl -p
Method 2: Disable IPv6 protocol via GRUB in Ubuntu
Another way to disable the IPv6 protocol in Ubuntu is to configure GRUB to pass kernel parameters at boot time:
Step 1 – Use a file editor such as VIM or Nano to edit the /etc/default/grub configuration file
Step 2 – Modify GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX to disable IPv6 at startup:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1" GRUB_CMDLINE_LINUX="ipv6.disable=1"
Step 3 – After the configuration file is modified, to make the settings effective, you need to execute the following commands in the “terminal”:
$ sudo
0 Comments