How To Disable IPv6 In RHEL / CentOS 7.x / Fedora 21

February 5, 2015 | By
| 1 Reply More

Hi everyone, today we'll learn what is IPv6 and how to disable IPv6 in our CentOS, Fedora,  RHEL distributions of Linux. Our policy and network configuration these days does not require IPv6 support.

Internet Protocol version 6 (IPv6) is the latest version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet. IPv6 was developed by the Internet Engineering Task Force (IETF) to deal with the long-anticipated problem of IPv4 address exhaustion.

IPv6 is intended to replace IPv4, which still carries more than 94% of Internet traffic worldwide as of December 2014. As of December 2014, the percentage of users reaching Google services with IPv6 surpassed 5% for the first time.

So, one wants to disable IPv6 in their Fedora based distributions of Linux because they are of no use currently. So, here are the steps by which we can easily disable IPv6 networking in our machine.

We can easily prevent the kernel module from loading IPv6 networking by updating the following two files:

  1. /etc/modprobe.conf - Kernel driver configuration file.
  2. /etc/sysconfig/network - RHEL / CentOS networking configuration file.

1. Editing Kernel Driver

We can prevent the kernel module to load IPv6 by edit /etc/modprobe.conf and adding install ipv6 /bin/true by executing the following commands in a shell or terminal. Make sure we switch to root or own sudo privilege.

$ sudo -s

# nano /etc/modprobe.conf

Then, we'll wanna append the following line:

install ipv6 /bin/true

append modprobe

Now, we'll save and close the file.

2. Editing Networking configuration file

We'll wanna edit /etc/sysconfig/network file and add no to NETWORKING_IPV6 and IPV6INIT . We can that by executing the below command in a shell or terminal.

# nano /etc/sysconfig/network

Now, we'll gonna append the file as follows:

NETWORKING_IPV6=no
IPV6INIT=no

Editing Network Config

We'll then save and close the file.

Now, after editing the files, we'll restart our network services.

# service network restart
# rmmod ipv6

restart network services

Finally, to verify whether IPv6 is disabled or not, we'll gonna run the below commands:

# lsmod | grep ipv6
# /sbin/ifconfig

checking ipv6

What If I get issues after disabling IPv6?

You may get problems after disabling IPv6.

Issue 1:

if you get issues with SSH after disabling IPv6, do the following.

Edit /etc/ssh/sshd_config file,

# nano /etc/ssh/sshd_config

Then, find the line #AddressFamily any and change it to AddressFamily inet as shown in the figure below.

Then remove the hash mark (#) in front of the line:

#ListenAddress 0.0.0.0

Then, restart ssh to reflect the changes.

# systemctl restart sshd

Issue 2:

If you get problems with starting postfix after disabling IPv6, edit /etc/postfix/main.cf file;

# nano /etc/postfix/main.cf

and comment out the localhost part of the config and use ipv4 loopback.

#inet_interfaces = localhost
inet_interfaces = 127.0.0.1

 Conclusion

Hurray, we'have finally disabled IPv6 Networking in our system which is pretty useless these days but might be pretty useful in coming generations. IPv6 is intended to replace IPv4, which still carries more than 94% of Internet traffic worldwide. So, using this tutorial one can easily disable IPv6 Networking in CentOS, Fedora and Redhat distributions of Linux. If you have any questions, comments, feedback please do write on the comment box below and let us know what stuffs needs to be added or improved. Thank You! Enjoy :-)

Filed Under : LINUX HOWTO, NETWORK

Free Linux Ebook to Download

Comments (1)

Trackback URL | Comments RSS Feed

  1. F. Baker says:

    There is no more modprobe.conf as of at least fedora 23. What now for that step?

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.