IPv6 offers many benefits over IPv4 such as auto-configuration, no address collision, better routing and quality of service. However, by default, IPv6 is disabled on many Linux systems. In this article, we will look at how to enable IPv6 in Linux.
How To Enable IPv6 in Linux
Here are the steps to enable IPv6 in Linux. Please note, IPv6 is enabled by default on RHEL/CentOS systems.
Here is the command to check if IPv6 is enabled or not.
# ifconfig -a | grep inet6 inet6 fe80::211:aff:fe6a:9de4 prefixlen 64 scopeid 0x20 inet6 ::1 prefixlen 128 scopeid 0x10[host]
If you see the above output, beginning with ipv6, it means IPv6 is enabled on your system.
However, if it is disabled on your Linux, then you can enable IPv6 in either of the two ways below:
Enable IPv6 in Kernel Module
This approach requires you to reboot.
1. Open GRUB file
Open terminal and run the following command to open grub file
$ sudo vi /etc/default/grub
Look for the following line
GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto rhgb quiet"
and change ipv6.disable from 1 to 0
GRUB_CMDLINE_LINUX="ipv6.disable=0 crashkernel=auto rhgb quiet"
Also read : How to Set Environment Variables in Linux
2. Generate GRUB configuration file
Generate GRUB configuration file, overwriting the existing file.
$ grub2-mkconfig -o /boot/grub2/grub.cfg
3. Restart system
Restart system to apply changes
$ shutdown -r now
Also read : How to Calculate CPU Utilization in Linux
Enable IPv6 using sysctl settings
It may also happen that IPv6 is disabled using sysctl settings. In this case, you do not need to reboot system.
1. Open Sysctl file
Open terminal and run the following command.
$ sudo vi /etc/sysctl.conf
Look for the following lines and comment them by adding # at their beginning.
# net.ipv6.conf.all.disable_ipv6 = 1 ### either comment/remove this line or change its value from 1 to 0 # net.ipv6.conf.default.disable_ipv6 = 1 ### either comment/remove this line or change its value from 1 to 0
Also read : How to Reduce Server load in Linux
2. Re-read configuration file
Reload configuration file using sysctl command
$ sysctl -p
Verify IPv6
Run the following command to verify IPv6
# ifconfig -a | grep inet6 inet6 fe80::211:aff:fe6a:9de4 prefixlen 64 scopeid 0x20 inet6 ::1 prefixlen 128 scopeid 0x10[host]
Depending on your requirement, you can use either of the above two methods to enable IPv6 in Linux.