How to disable IPv6 networking on CentOS|RHEL|Ubuntu|Debian

Ipv6

Internet Protocol Version 6 (IPv6) is a network layer protocol which allows communication and data transfers to take place over the network. IPv6 came into existence in 1998 with the sole purpose to take over and replace IPv4 protocol. This article describes about various methods to disable IPV6 networking on Linux system.

Topic

  • How to disable IPv6 networking on CentOS|RHEL|Ubuntu|Debian?
  • How to disable IPV6 on Linux?
  • Process to disable IPV6 Networking
  • Enable IPV6 Netwkrong of CentOS|RHEL|Ubuntu|Debian

apt

  • Linux
  • Ubuntu
  • CentOS
  • RHEL
  • Debian

solution


Disable IPV6 Networking

There are two methods to disable IPV6 networking on a CentOS6,7,8 or RHEL6,7,8, Ubuntu and Debian system.

  1. Disable IPV6 with sysctl kernel parameters (No system reboot required)
  2. Disable IPV6 module from the grub command line ( System reboot required)

Check whether IPV6 is enabled on the system with the following command. Replace enp0s3 with name of the Ethernet adapter such as eth0, eth1, etc.

# ip addr show enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:2b:f1:95 brd ff:ff:ff:ff:ff:ff
    inet 192.168.x.x/24 brd 192.168.x.x scope global noprefixroute enp0s3
       valid_lft forever preferred_lft forever

    inet6 fe80::1702:97a9:bbb3:2be4/64 scope link noprefixroute   <<<<<<<<< Here
       valid_lft forever preferred_lft forever 

inet6 from above command output confirms that IPV6 networking is enabled. Now lets look at disabling IPV6 networking.

[Method 1 – Disable IPV6 with sysctl kernel parameters (No reboot )]

Add the following kernel parameters to /etc/sysctl.conf file to disable IPV6 networking completely on the system.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

Optional: Apply the following configuration to /etc/sysctl.conf file, If there is a need to disable IPV6 networking for a single network interface such as eth1, eth2, etc.

net.ipv6.conf.[interface].disable_ipv6 = 1

In the above line, replace [interface] with the actual network interface card name.  Eg. 
net.ipv6.conf.eth1.disable_ipv6 = 1
net.ipv6.conf.eth2.disable_ipv6 = 1

validate configuration using the following command and then reboot the system for settings to take place.

  # sysctl -p 
  # reboot 

After system reboot we can see that IPV6 network IP details doesn’t appear in the following command.

# ip addr show enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:2b:f1:95 brd ff:ff:ff:ff:ff:ff
    inet 192.168.x.x/24 brd 192.168.x.x scope global noprefixroute enp0s3
       valid_lft forever preferred_lft forever


[Method 2 – Disable IPV6 module from the grub command line ( reboot required)]

In /etc/default/grub file, append ipv6.disable=1 to the GRUB_CMDLINE_LINUX config line with the following example.

[...]
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap  ipv6.disable=1 rhgb quiet"
[...]

Execute the following command regenerate the grub.cfg file:

   # grub2-mkconfig -o /boot/grub2/grub.cfg

On UEFI or EFI boot systems, run the following command regenerate the grub.cfg file:

    # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

On Ubuntu or Debian system execute the following command to regenerate grub.cfg file.

# update-grub

Then reboot the system and validate


Enable IPV6 networking

  • Remove sysctl parameters from sysctl.conf file if exist.
  • Remove ipv6.disable=1 parameter from grub command line from /etc/default/grub file if exist.
  • Execute the following command regenerate the grub.cfg file.
   # grub2-mkconfig -o /boot/grub2/grub.cfg

  • On UEFI or EFI boot systems, run the following command regenerate the grub.cfg file:

    # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

  • On Ubuntu or Debian system execute the following command to regenerate grub.cfg file.

    # update-grub

  • Reboot the system and validate

  • If settings don’t take place, rebuild initramfs with the following command then reboot the system.

    # dracut -f

You May Also Like

avatar

About the Author: TekFik

TekFik is a technical blogging site helps techies and engineers to solve their day to day issues and also allows everyone to share knowledge and feedback. Please feel free to contact us at tekfik.rd@gmail.com if there is anything.

Leave a Reply

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