If we are not using IPv6 in our environment why can’t we go-head to disable it?. Extremely this is not a good idea to disable a feature and stop using it. However, let’s walk through it, this may help someone who is looking to disable IPv6
In this guide, we are about to see how to disable the IPv6 in Linux servers. In most of the production environment we have not yet started with implementing IPv6, Top companies like Akamai, Vmware, Comcast are started using long back. This may take another few years to come into prod for thousands of firms. Let’s continue to disable IPv6 in various Linux flavours.
Red Hat Linux 6 and Family
Method 1: Disable using module and service
Create a file ipv6.conf under modprobe.d and disable the service persistently and reboot the server to take effect.
# echo "options ipv6 disable=1" > /etc/modprobe.d/ipv6.conf # chkconfig ip6tables off # reboot
Once module disabled take a reboot.
Method 2: Disable using "sysctl" and reboot
Edit the sysctl.conf and append with two lines. Changing from 1 to 0 will re-enable the IPv6.
# vi /etc/sysctl.conf net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1
If /etc/hosts have any IPv6 entry make sure to remove them. For some applications it's mandatory to have IPv6 entry in /etc/hosts.
Steps for Red Hat Linux 7 and Family
Method 1: Disable using "sysctl", we can disable the IPv6 by including interface name in sysctl.conf configuration.
Now we are enabled with IPv6 as per the "
ifconfig" output and /proc output.
[root@splunk ~]# ifconfig | grep -i 'inet6' inet6 fe80::a336:2382:1d66:2285 prefixlen 64 scopeid 0x20<link> inet6 ::1 prefixlen 128 scopeid 0x10<host> [root@splunk ~]# [root@splunk ~]# cat /proc/sys/net/ipv6/conf/all/disable_ipv6 0 [root@splunk ~]#
Let us disable and verify the same.
Edit the sysctl.conf and append with configurations.
# vi /etc/sysctl.d/99-sysctl.conf net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 net.ipv6.conf.lo.disable_ipv6 = 1 net.ipv6.conf.ens33.disable_ipv6 = 1
Now let us verify the same.
[root@splunk ~]# cat /proc/sys/net/ipv6/conf/all/disable_ipv6 1 [root@splunk ~]# [root@splunk ~]# ifconfig | grep -i 'inet6' [root@splunk ~]#
In our test environment, we have the localhost (lo) interface and 1 management interface (ens33).
Once done with sysctl configuration rebuild the Init RAM image and reboot the server.
# dracut -f
Using "sysctl" we have disabled successfully.
Method 2: Disable using the kernel parameter.
Edit the grub and append with "ipv6.disable=1". Removing or making 1 to 0 will re-enable the IPv6 for all available interfaces.
# vi /etc/default/grub GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap ipv6.disable=1 rhgb quiet"
Rebuild the grub using "grub2-mkconfig" and reboot the server.
# grub2-mkconfig -o /boot/grub2/grub.cfg # reboot
After making changes to grub take a reboot to make it effect.
Disable IPv6 in Ubuntu Linux
To disable IPv6 in Ubuntu is not too far different from RHEL base OS. In below "
ifconfig" output we are able to see IPv6 address lets disable and check the result.
sysadmin@ubuntu:~$ ifconfig | grep -i 'inet6' inet6 addr: fe80::20c:29ff:fe53:dd19/64 Scope:Link inet6 addr: ::1/128 Scope:Host sysadmin@ubuntu:~$
Edit the sysctl configuration file and append with three lines at the end of the file.
$ sudo vi /etc/sysctl.d/99-sysctl.conf net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
Run with "
sysctl -p" command to make the changes effect.
Verify the changes, If we get value 1 then IPv6 has been disabled.
$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6
Now, whenever we run "
ifconfig" we don't get IPv6 information.
If you need to disable IPv6 in Arch Linux exactly the Ubuntu steps can be followed. That's it we have seen how to disable IPv6 in various Linux flavours.
To disable IPv6 in Linux we need to follow only few steps, however this is not a good practise to disable the feature instead of using it. Provide your feedback in below comment section and subscribe to our news letter.