By default IPv6 is enabled on installed CentOS and Redhat. In this article I will explain how to disable IPv6 in CentOS and Redhat.
Disable IPv6 in CentOS and Redhat
First of all check the configuration of the existing network with the “ifconfig” command. If inet6 appears in the configuration, means IPv6 is enabled.
[root@look ~]# ifconfig eth0 Link encap:Ethernet HWaddr 12:57:7B:56:74:B4 inet addr:192.168.0.5 Bcast:172.30.3.255 Mask:255.255.255.0 inet6 addr: fe80::1057:7bff:fe56:74b4/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:9001 Metric:1 RX packets:1592001 errors:0 dropped:0 overruns:0 frame:0 TX packets:896813 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:944612392 (900.8 MiB) TX bytes:1004972537 (958.4 MiB) Interrupt:17 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:836996 errors:0 dropped:0 overruns:0 frame:0 TX packets:836996 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:252767227 (241.0 MiB) TX bytes:252767227 (241.0 MiB) You have new mail in /var/spool/mail/root
Follow the below steps to disable IPv6 on CentOS and Redhat.
1. Edit /etc/sysctl.conf file.
Method #1:
# vim /etc/sysctl.conf
Add the following :
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1
Run the below command to apply the changes.
# 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. Edit config file in/etc/sysconfig/network-scripts/ifcfg-eth0 and /etc/sysconfig/network-scripts/ifcfg-ens160.
On 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.5 NETMASK=255.255.255.0 IPV6INIT=no
On 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.6" 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 the “no” to NETWORKING_IPV6.
# vi /etc/sysconfig/network NETWORKING_IPV6=no
I will suggest you to restart network configuration as shown below.
On CentOS 6:
# service network restart
On CentOS 7:
# systemctl restart network
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment