How to Disable IPv6 on Redhat / CentOS 6 / CentOS 7

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, means IPv6 is enabled.

Disable IPv6 on Redhat

Here are details on 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

Disable IPv6 on Redhat

Method 2 :

READ  How to Copy and Paste Text in one line With vi or vim in Linux

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"

Disable IPv6 on Redhat

3. Edit /etc/sysconfig/network file and add “no” to NETWORKING_IPV6.

# vi /etc/sysconfig/network
NETWORKING_IPV6=no

Disable IPv6 on Redhat

I would advise you to restart 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
  1. Subramaniyam Sankar
    Subramaniyam Sankar
    September 26, 2017 at 4:24 pm

    Superb..! Thanks

    Reply
Leave a Reply

Your email address will not be published. Required fields are marked *

SiteGround.com

A world leading hosting company that provides fully-managed innovative and secure solutions, suitable for hosting small to medium-sized websites

Built on the best available technologies combined with Google Cloud for strong redundancy and application availability. Backed by skilled experts to address web security threats, a devops team to create advanced custom security solutions, and 24/7 sysadmins to watch over the platform. This powerful, hands-on approach makes your sites faster, safer, and easier to manage. Starting from only $3.95/mo.

TRY FREE

* up to 30 days money back guarantee