This howto will show you how to disable IPv6 on RHEL 6/7, CentOS 6, and CentOS7.
IPv6 is enabled by default. In this article, I summarize 3 configuration which needs to be changed to completely disable IPv6.
Check the configuration of the existing network with the “ifconfig” command. If inet6 appears in the configuration, that means IPv6 is enabled.
Here’s how to disable IPv6 on Redhat / CentOS 6 / CentOS 7:
1. Update /etc/sysctl.conf:
Method 1:
# vi /etc/sysctl.conf
Add the following :
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1
Run the following command to take effect.
# sysctl -p
Method 2:
To disable ipv6 in the running system:
# echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 # echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
or
# sysctl -w net.ipv6.conf.all.disable_ipv6=1 # sysctl -w net.ipv6.conf.default.disable_ipv6=1
2. Update config file in/etc/sysconfig/network-scripts/ifcfg-eth0 and /etc/sysconfig/network-scripts/ifcfg-ens160:
For CentOS 6:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 HWADDR=00:0C:29:C5:36:7C TYPE=Ethernet UUID=f9db89e6-013a-4403-8893-ae0536c6306f ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static IPADDR=192.168.0.9 NETMASK=255.255.255.0 IPV6INIT=no
For CentOS 7:
# vi /etc/sysconfig/network-scripts/ifcfg-ens160
TYPE="Ethernet" BOOTPROTO="static" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="no" IPV6_AUTOCONF="no" IPV6_DEFROUTE="no" IPV6_FAILURE_FATAL="yes" NAME="ens32" UUID="ccfd7425-20ab-40c9-a141-b71828a1b8bf" DEVICE="ens160" ONBOOT="yes" IPADDR="192.168.0.100" PREFIX="24" GATEWAY="192.168.0.1" DNS1="8.8.8.8" DOMAIN="ehowstuff.local" IPV6_PEERDNS="no" IPV6_PEERROUTES="no" IPV6_PRIVACY="no"
3. Edit /etc/sysconfig/network file and add “no” to NETWORKING_IPV6.
# vi /etc/sysconfig/network
NETWORKING_IPV6=no
I would advise you to restart the network configuration as below:
For CentOS 6:
# service network restart
For CentOS 7:
# systemctl restart network
Source : https://wiki.centos.org/FAQ/CentOS6
2 Comments
Thank you for the useful article.
You can also check it using ip command: ip -6 addr
Extracted from: http://www.sysadmit.com/2017/09/linux-deshabilitar-ipv6.html
Superb..! Thanks