By default, IPv6 is enabled on CentOS/RHEL 8 systems. However, in certain situations, some users may find it desirable to disable IPv6 support. This post outlines steps to enable ipv6 on a CentOS/RHEL 8 system.
1. Edit /etc/default/grub and delete the entry ipv6.disable=1 from the GRUB_CMDLINE_LINUX, as shown below:
# vi /etc/default/grub GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root"
2. Run the grub2-mkconfig command to regenerate the grub.cfg file:
# grub2-mkconfig -o /boot/grub2/grub.cfg
Alternatively, on UEFI systems, run the following:
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
3. Delete the file /etc/sysctl.d/ipv6.conf which contains the entry:
# First, disable for all interfaces net.ipv6.conf.all.disable_ipv6 = 1 # If using the sysctl method, the protocol must be disabled all specific interfaces as well. net.ipv6.conf.[interface].disable_ipv6 = 1
If the Initial RAM Disk image was created earlier while disabling IPv6, only then carry out this step.
# dracut -f
4. Check the content of the file /etc/ssh/sshd_config and make sure the AddressFamily line is commented:
# vi /etc/ssh/sshd_config #AddressFamily inet
5. Make sure the following line exists in /etc/hosts, and is not commented out:
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
6. Reboot the system to enable IPv6 support.
# systemctl reboot
1. The current state of the ipv6 module disable option can be seen via sysfs:
# cat /sys/module/ipv6/parameters/disable 1
2. The current state of the sysctl disable_ipv6 can be seen with the sysctl command:
# sysctl -a 2>/dev/null | grep disable_ipv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 0 net.ipv6.conf.eth0.disable_ipv6 = 0
3. To list any IPv6 addresses assigned to the system:
# ip -6 addr
4. To list any IPv6 TCP or UDP sockets something like the following can be used:
# ss -6 -pan