Cyberithub

How to Enable IPV6 on Linux(CentOS / RHEL 7) Using 4 Easy Steps

In this article, I will take you through the Steps to Enable IPV6 on CentOS / RHEL 7 Using 4 Easy Steps. You might have seen some program which requires IPV6 to be enabled in your System or else it will fail and will unable to execute. In those situations you need to manually enable IPV6 modules. While in most of the Linux/Unix Systems you will find IPV6 enabled by default but there are few instances where you won’t see it is enabled due to various reasons. We will look into the different steps in the below sections that needs to be taken to enable IPV6 modules in Linux/Unix Based Systems.

How to Enable IPV6 on Linux(CentOS / RHEL 7) Using 4 Easy Steps 1

How to Enable IPV6 on CentOS / RHEL 7

Also Read: 10 Popular modprobe command examples in Linux/Unix (View, Install and Remove Modules)

Step 1: Verify if IPV6 is Enabled or not

You can verify if IPV6 is enabled or not by simply running ifconfig eth0 command as shown below. As you can see from below output, since inet6 is not showing here hence it is currently not enabled. There are other ways to verify this but this is the most simplest way.

[root@localhost ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 172.31.33.220 netmask 255.255.240.0 broadcast 172.31.47.255
ether 06:23:b3:d6:e9:76 txqueuelen 1000 (Ethernet)
RX packets 1536 bytes 164873 (161.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2715 bytes 269086 (262.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

NOTE:

Please note that here I am using root user to run all the below commands.You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User.

Step 2: Enable IPV6 from /etc/sysctl.conf file

You need to add below Lines at the end of /etc/sysctl.conf to disable IPV6. If the below parameter is already available in /etc/sysctl.conf file then you need to change the value to 0.

[root@localhost ~]# vi /etc/sysctl.conf
....................................................
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0

Then you need to run sysctl -p to reflect the changes in the System.

[root@ip-172-31-33-220 ~]# sysctl -p
fs.inotify.max_user_watches = 524288
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
kernel.core_pattern = /cores/cores-%e-%s-%t-%p.core
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

Now you can check again if ipv6 is disabled or not using ifconfig eth0 command as shown below.

[root@localhost ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 172.31.33.220 netmask 255.255.240.0 broadcast 172.31.47.255
ether 06:23:b3:d6:e9:76 txqueuelen 1000 (Ethernet)
RX packets 1536 bytes 164873 (161.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2715 bytes 269086 (262.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Step 3: Enable IPV6 from GRUB(/etc/default/grub)

To enable IPV6 from GRUB you need to either put ipv6.disable=0 or you need to remove ipv6.disable from GRUB_CMDLINE_LINUX as shown below.

[root@localhost ~]# vi /etc/default/grub
GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --speed=115200"
GRUB_CMDLINE_LINUX="ipv6.disable=0 console=tty0 crashkernel=auto console=ttyS0,115200"
GRUB_DISABLE_RECOVERY="true"

Then you need to regenerate the grub configuration file again using grub2-mkconfig -o /boot/grub2/grub.cfg command as shown below.

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1062.12.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.12.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.1.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.1.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-05cb8c7b39fe0f70e3ce97e5beab809d
Found initrd image: /boot/initramfs-0-rescue-05cb8c7b39fe0f70e3ce97e5beab809d.img
done

After regenerating the file you need to reboot the system using reboot or init 6 command to reflect the changes in the System.

[root@localhost ~]# reboot

Step 4: Enable IPV6 Using sysctl command

If you want to enable IPV6 protocol for any specific interface then you need to use below sysctl commands to change the value of net.ipv6.conf.eth0.disable_ipv6 and net.ipv6.conf.default.disable_ipv6 to 0. In this example, we are trying to enable IPV6 setting of eth0 interface.

[root@localhost ~]# sysctl net.ipv6.conf.eth0.disable_ipv6=0
net.ipv6.conf.eth0.disable_ipv6 = 0
[root@localhost ~]# sysctl net.ipv6.conf.default.disable_ipv6=0
net.ipv6.conf.default.disable_ipv6 = 0

If you want to enable IPV6 protocol for all the interfaces then you need to use below sysctl commands to change the value of net.ipv6.conf.all.disable_ipv6 and net.ipv6.conf.default.disable_ipv6 to 0.

[root@localhost ~]# sysctl net.ipv6.conf.all.disable_ipv6=0
net.ipv6.conf.all.disable_ipv6 = 1
[root@localhost ~]# sysctl net.ipv6.conf.default.disable_ipv6=0
net.ipv6.conf.default.disable_ipv6 = 1

 

 

 

Popular Recommendations:-

How to Limit CPU Limit of a Process Using CPULimit in Linux (RHEL/CentOS 7/8)

How to Install Rust Programming Language in Linux Using 6 Best Steps

How to Install LEMP Stack on CentOS 8

Openssl Tutorial: Generate and Install Certificate on Apache Server in 8 Easy Steps

How to Enable or Disable SELinux Temporarily or Permanently on RedHat/CentOS 7/8

10 Popular Examples of sudo command in Linux(RedHat/CentOS 7/8)

25+ Popular Examples of Openssl commands in Linux (RedHat/CentOS 7/8)

12 Most Popular rm command in Linux with Examples

Create a Self Signed Certificate using OpenSSL

Top 12 Nmap Commands to Scan Remote Host with Best Practices

Leave a Comment