Planning to turn off or disable IPv6 on your Ubuntu VPS ? In this article, we will discuss how to do it, including how to check if IPv6 is currently active on your server.
When using a VPS, we typically get three types of IP addresses, one of which is IPv6, used to improve security and connection performance. However, there is no denying that we might need to turn off or disable IPv6 for certain purposes.
How to Disable IPv6 on an Ubuntu VPS
It would be quite strange if we wanted to disable IPv6 on our server only to find out that our VPS does not support it or that it is already disabled. So, here we will first discuss how to check whether IPv6 is active on our server or not.
Check IPv6 Status
There are several ways to turn off or disable IPv6 on Ubuntu, as well as ways to check it.
Usually, when opening a guide page, we might use the command ip a to check our server IP. However, when we try it, we might get an error or the results might not be as expected, something like this
ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 ......... valid_lft forever preferred_lft forever2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 ......... valid_lft forever preferred_lft forever3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 ......... valid_lft forever preferred_lft foreverSo, how do we check if IPv6 is active on our server or not? It is easy. First, we can check the status of the IPv6 module directly with this command
cat /sys/module/ipv6/parameters/disableIf IPv6 is active, the output will be 0 (Zero) and if the status is disabled, the output will be 1 (One).
If the first method does not work, we can check the status using sysctl
sysctl -a 2>/dev/null | grep disable_ipv6If IPv6 is still active, the result is the same. We will get an output of 0 (Zero) and will get a value of 1 if the status is disabled, but with some additional details, something like this
root@user:~# sysctl -a 2>/dev/null | grep disable_ipv6
net.ipv6.conf.all.disable_ipv6 = 0net.ipv6.conf.default.disable_ipv6 = 0net.ipv6.conf.eth0.disable_ipv6 = 0net.ipv6.conf.eth1.disable_ipv6 = 0net.ipv6.conf.lo.disable_ipv6 = 0Disable IPv6 via Sysctl (Recommended)
This method is recommended because we do not need to edit files on our server, and it can be done easily.
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1For the changes to be saved, we need to load the configuration we added previously with the following command
sudo sysctl -pNow, if you check again, IPv6 should be disabled. If IPv6 becomes active after a reboot, you can try to disable IPv6 via GRUB.
Disable Using GRUB
To disable IPv6 using GRUB, it is recommended to log in to the VPS as root, then we can edit the file /etc/default/grub using Nano or Vim editor. Here, for example, we are using Nano
sudo nano /etc/default/grubAfter the editor is open, search for GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX to turn off IPv6 when a reboot is performed.
Change both lines to look like this
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"GRUB_CMDLINE_LINUX="ipv6.disable=1"Now we can exit the editor and save the changes, then perform a GRUB update with this command
sudo update-grubTry checking the IPv6 status again, and if it was successfully turned off via GRUB, then the command sysctl -a 2>/dev/null | grep disable_ipv6 will not display any output.
Those are two easy ways to turn off or disable IPv6 on an Ubuntu VPS. To enable it again, we just need to undo those changes.
COMMENTS
Loading...